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
I think this is an endless game of whack-a-mole. I think in general type-checking is impossible, take for example:
selectsqlc.arg('string_or_float')::intas x
how can sqlc know what type the first arg is? It can be anything castable to int - including a string or floating point number, numeric(10, 2), etc. I (personally) believe you need to give the developer control over this.
I think my proposal: #1525 would at least give the developer control of this behavior, which would allow sqlc to still be usable (but less magic), and also would leave room for "adding magic" in the future. (because theoretically this individual case should be type-checkable).
-- name: GetRestrictedId :oneSELECTsqlc.output(
NULLIF(id, sqlc.arg('ignore_id', 'type', 'bigint', 'nullable', false)),
'nullable', true) as restricted_id
FROM
author;
Version
1.14.0
What happened?
Actually, NULLIF also smells bad. When using it in a query, the Go struct is generated with a field with a bool type, instead of a NullInt64 type.
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/321eb83b945edfab5a41d8c91feb596bcab9860ce1780639d1f9863207a20644
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
Originally posted by @euller88 in #92 (comment)
The text was updated successfully, but these errors were encountered: