ehmpathy / sql-dao-generator

Generate data-access-objects from your domain-objects
MIT License
0 stars 0 forks source link

when fk reference by uuid is nullable, it should write the query in a way that sql-code-generator can understand that #12

Open uladkasach opened 1 year ago

uladkasach commented 1 year ago

currently, have case where

interface WorkPost {
  workUuid: string | null; // fk to Work domain object, in same db
}

which results in

  -- query_name = upsert_work_post
  SELECT
    dgv.id, dgv.uuid, dgv.created_at
  FROM upsert_work_post(
    :providerUuid,
    :externalId,
    (SELECT id FROM work WHERE work.uuid = :workUuid ),
    :completedAt,
    :title,
    :description,
    :photoImageUuids
  ) as dgv;

for which the sql-code-generator defines a type def for input workUuid as string, where it needs to allow string|null

we should be able to inform sql-code-generator that it could take on null simply by defining the where condition of that subselect as :workUuid is null or work.uuid = :workUuid instead of just work.uuid = :workUuid