-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
feat(sql.unsafe): add optional typearg for row type #512
Conversation
The default type is still ZodTypeAny. This is essentially a non-breaking change that makes sql.unsafe *less* unsafe at compile time, without changing its runtime behaviour.
Thanks. Being non-zod specific would be awesome, I could absolutely help with that. I will comment there too. |
@gajus any thoughts on this? |
Ping - @gajus can we merge this? |
My problem with this is that it encourages the use of The only valid use case for I fail to see in what context this would be valuable that's not already covered by what's provided by @slonik/migrator does not need this (?). Meanwhile, I don't want to promote/encourage usage of @slonik/typegen as I see it as an unsafe pattern. It comes down to my personal belief that an API that bridges two remote systems must provide build time and runtime guarantees in order to be considered reliable. |
The default type is still a zod type producing
any
as its output, as before.This is essentially a non-breaking change that makes sql.unsafe less unsafe at compile time, without changing its runtime behaviour.
Copying the type test to demonstrate how it can be used:
Note @gajus: with this change, @slonik/migrator and @slonik/typegen should be able to upgrade and support slonik version 37. It already supports 29 so I guess we could bypass 30, 31, 32, 33, 34, 35, and 36 - i.e. all the breaking changes this library has produced in the last year or so.