Use optional field instead of null
louneskmt opened this issue · 2 comments
Internally (at the Postgres client level), I convert all null
values to undefined
. It is not uncommon to only handle undefined
and completely drop null
. I use some tricks to adapt the Kanel outputs to this scheme (i.e. converting all nullable properties to optional properties with no null
union), but do you think it is something it would makes sense to support natively? Or is that too project-specific?
Hm, I would say that I would like to hear from at least another person or two who does something similar.
As is evident from the other issues, the configuration system is overwhelmingly complex as it is, so if you have a solution that works, maybe that's worth sticking with for now?
For the record and future readers of this issue, here is the getPropertyMetadata
I'm using (see the documentation on configuration):
getPropertyMetadata(property, details, generateFor, config) {
const metadata = defaultGetPropertyMetadata(
property,
details,
generateFor,
config
)
if (property.isNullable) {
metadata.nullableOverride = false
metadata.optionalOverride = true
}
return metadata
}
This one is way cleaner of the big .replace
I was using before haha
Note that it needs #441 in order for it to work for views.