You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above drizzle-kit version may not be accurate - I didn't see a way to view it in the playground. Applies at least to both SQLite and Postgres.
Generated columns should not accept a value for an insert nor should they be altered directly. However, the insert schema generated from the playground returns an object of all 5 columns as optional; parsing or safe-parsing the object sets the value given as if ignored. Drizzle does properly ignore those columns when inserting, but passing the object to said function returns no errors.
I would think that one at least one of the following should have happened:
The createInsertSchema function does not return the generated columns or they are returned as ZodReadOnly
The parse function throws an error for unknown properties
Drizzle throws an error when an object passed to values does not meet the criteria
If the above cannot be done, could we add a readOnly or similar that would otherwise enforce this? In SQL Server, you have to explicitly call IDENTITY INSERT OFF, for example to insert values into an identity column. I know it's not quite the same, but I need a way to generate values without worrying about rogue actors. The solution to this (however it comes to be) could be a good candidate for the eslint plugin as well.
As an aside, the much simpler example from docs does not work. I've commented the errors I received in the playground. Since I can replicate it otherwise and it's out of scope, I didn't check to see if they already existed in the issue list. I can add those separately if needed.
The text was updated successfully, but these errors were encountered:
Adding for more impact use cases: I have a not-null generated column, so I need to manually omit is from the createInsertSchema result otherwise it wreaks havoc on my input validation.
Report hasn't been filed before.
What version of
drizzle-orm
are you using?0.36.0
What version of
drizzle-kit
are you using?0.28.0
Other packages
drizzle-zod@0.5.1
Describe the Bug
Playground: https://drizzle.run/tnqgqasce82gq05mipu7whwm
The above drizzle-kit version may not be accurate - I didn't see a way to view it in the playground. Applies at least to both SQLite and Postgres.
Generated columns should not accept a value for an insert nor should they be altered directly. However, the insert schema generated from the playground returns an object of all 5 columns as optional; parsing or safe-parsing the object sets the value given as if ignored. Drizzle does properly ignore those columns when inserting, but passing the object to said function returns no errors.
I would think that one at least one of the following should have happened:
createInsertSchema
function does not return the generated columns or they are returned as ZodReadOnlyparse
function throws an error for unknown propertiesIf the above cannot be done, could we add a
readOnly
or similar that would otherwise enforce this? In SQL Server, you have to explicitly callIDENTITY INSERT OFF
, for example to insert values into an identity column. I know it's not quite the same, but I need a way to generate values without worrying about rogue actors. The solution to this (however it comes to be) could be a good candidate for the eslint plugin as well.As an aside, the much simpler example from docs does not work. I've commented the errors I received in the playground. Since I can replicate it otherwise and it's out of scope, I didn't check to see if they already existed in the issue list. I can add those separately if needed.
The text was updated successfully, but these errors were encountered: