-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should nullable columns always be optional? #76
Comments
I agree that nullable columns should "default" to |
Thinking about it, you've convinced me. Given the following different column null / default configurations.
Should output the following
Essentially null acts like a default and the only instance in which a column isn't optional is when it's not nullable and there's no default value. I've gone through and updated all dialects to work as above, fixing a couple of bugs along the way. Hopefully be able to get it out within a day or so. |
This is fixed in version 1.10.0. All clients have had their optionality and nullability standardised as per the above. |
Given this table in a PostgreSQL database:
I can run the following query:
However,
sql-ts
will generate types that look like this:which makes specifying
value_two
mandatory. I think a more correct type would be:I can get around it by modifying the handlebars template:
It seems though that perhaps
optional
should be true for columnvalue_two
since I don't need to provide a value for this column in anINSERT
. Is there something I might be missing?The text was updated successfully, but these errors were encountered: