Comments (2)
I just ran into a similar issue. Here's the query which is used to determine whether an insert would put the number of inserted rows matching a condition over a limit:
INSERT INTO foo (bar)
SELECT $1
FROM foo
WHERE tenant_id = $2
HAVING count(*) < $3
RETURNING *;
package query
test.sql:14:17: no column reference found
@nzoschke's workaround works somewhat in that this query works:
INSERT INTO foo (bar)
SELECT $1
FROM foo
WHERE tenant_id = $2
HAVING (count(*)::INTEGER) < $3
RETURNING *;
but it has two problems:
- that's unintuitive
- (more importantly) the generated column name is
Column3
which is both confusing and also will cause the code to break in an unexpected way if the parameter ordinals get changed
from sqlc.
@nzoschke thanks for the report. mb_downloaded
was being left out because I hadn't added support for mathematical operators. I'm fixing that now.
@inconshreveable your problem appears to be different. I can't reproduce it. Can you open a new issue with a self-contained example? I tried the following SQL but couldn't get it to generate code. It failed with an no column reference found
.
CREATE TABLE foo (id text not null);
INSERT INTO foo (id)
SELECT $1 FROM foo
HAVING count(*) < $2
RETURNING *;
from sqlc.
Related Issues (20)
- sqlc.embed(<right_join_table>) should generate NULLable fields in LEFT/RIGHT JOIN HOT 1
- Dynamically fetch the package name for single import strings HOT 1
- Support for Turso (libsql) HOT 1
- SQLite generating code error HOT 1
- Generic Interceptor/Middleware for caching, retry, circuit breaker, etc. HOT 2
- Capital letters in table alias causes generation to fail HOT 1
- Add support for COPY command in bulk inserts with lib/pq driver
- NOT NULL is ignored in DOMAIN
- Interface should include WithTx()
- Left joining same table as FROM statement results in unexpected string type rather than a nullable string type HOT 2
- UUID is not correctly overridden HOT 3
- go: expose DBTX inside Queries (via flag) HOT 4
- Typecast for nullable types
- Support generating pointers for nullable enum types (emit_pointers_for_null_types for enums)
- Automatically infer the types and use better Column names like offset and limit HOT 2
- Vetting doesn't seem to pick up column names being altered HOT 1
- config "output_querier_file_name" does not work properly
- RECURSIVE cte failed with `star expansion failed for query` HOT 1
- Can't generate only schema without queries
- Identical select statement produces two different return objects
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.