ehmpathy / sql-dao-generator

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

support nullable domain-value-object reference #11

Open uladkasach opened 1 year ago

uladkasach commented 1 year ago

right now, in the upsert function, it is trying to resolve the domain value object id without checking if the input for that property was null

typescript is catching this so no biggie, but its making the user have to fix it themselves

uladkasach commented 1 year ago

e.g., from


      searchTermId: googleAdsExposureTrigger.searchTerm.id
        ? googleAdsExposureTrigger.searchTerm.id
        : (
            await googleAdsSearchTermDao.upsert({
              dbConnection,
              googleAdsSearchTerm: googleAdsExposureTrigger.searchTerm,
            })
          ).id,

to


      searchTermId: googleAdsExposureTrigger.searchTerm
        ? googleAdsExposureTrigger.searchTerm.id
          ? googleAdsExposureTrigger.searchTerm.id
          : (
              await googleAdsSearchTermDao.upsert({
                dbConnection,
                googleAdsSearchTerm: googleAdsExposureTrigger.searchTerm,
              })
            ).id
        : null,