Comments (2)
I think this is an endless game of whack-a-mole. I think in general type-checking is impossible, take for example:
select
sqlc.arg('string_or_float')::int as 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 :one
SELECT
sqlc.output(
NULLIF(id, sqlc.arg('ignore_id', 'type', 'bigint', 'nullable', false)),
'nullable', true) as restricted_id
FROM
author;
from sqlc.
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
from sqlc.
Related Issues (20)
- Using domain to create custom numeric data type leads to interface{} HOT 1
- Ambiguous column checking creates false positives
- Cannot pass empty values for sqlc.slice
- Generated query will return row struct instead of table model struct selecting columns out of defined order.
- Generate fails for UPDATE with JOIN
- The sum of lengths becomes a float instead of an int. HOT 1
- The input for the comparison to the sum of length should be of type int.
- mysql copyfrom method not included in generated querier interface
- Not recognizing sqlc.arg after ON CONFLICT.
- getting-started-sqlite.md - wrong return value of queries.CreateAuthor
- 1.26.0 crashes on subquery without alias
- query execlastid for pgx/v5 is silently ignored
- Cannot use option "initialisms" from the documentation HOT 1
- Generate fails for UPDATE ... FROM (...) with subquery HOT 1
- Query "SELECT * FROM unnest(..)" has wrong generated code
- Determine which indices are needed for efficient execution of a query HOT 5
- Interpret schema migrations numerically
- Temp table created using schema.sql is not insertable. HOT 3
- Incorrect code gen without
- Basic usage - relation "x" does not exist HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlc.