Open khromov opened 2 months ago
After some sleuthing I found https://github.com/adelsz/pgtyped/issues/118 which seems related. It would be great if simple INSERT statements like these could be supported without having to manually enforcing non-nullability for parameters.
https://pgtyped.dev/docs/sql-file#enforcing-non-nullability-for-parameters
Describe the bug 👋 Perhaps I am misunderstanding something basic, consider this table:
& then we write this query:
Because all of the columns are
NOT NULL
, I would expect all the parameters to be required, however the generated type is:This in turns allows us to easily create a broken query:
Getting the error:
Expected behavior The parameters should be required because it should be possible to infer that the columns are not nullable!
You can work around this by manually marking the columns as non-nullable, eg
VALUES (:name!, :avatar!, :profile!, :phone!, :email!)
, this generated the correct type:...but why does it not infer it correctly out of the box?
Test case
N/A