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;
Activity
skabbes commentedon Apr 2, 2022
I think this is an endless game of whack-a-mole. I think in general type-checking is impossible, take for example:
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).
kyleconroy commentedon Oct 24, 2023
This is fixed in v1.23.0 by enabling the database-backed query analyzer. We added a test case for this issue so it won’t break in the future.
You can play around with the working example on the playground
Jonathan-Landeed commentedon Feb 12, 2025
I still get this issue in views.