- Notifications
You must be signed in to change notification settings - Fork 954
Closed
Labels
Description
Version
1.14.0
What happened?
the above query does not compile using sqlc generate.
Relevant log output
# package orm queries/users.sql:8:5: column "rank_email" does not exist
Database schema
CREATE EXTENSION pg_trgm; CREATE EXTENSION pgcrypto; CREATE TABLE users( id INT GENERATED ALWAYS AS IDENTITY NOT NULL, fname VARCHAR(100) NOT NULL, lname VARCHAR(100) NOT NULL, email VARCHAR(100) NOT NULL UNIQUE, enc_passwd TEXT NOT NULL, created_at TIMESTAMP WITH TIME ZONE NOT NULL default (NOW() AT TIME ZONE 'utc'), PRIMARY KEY(id) );
SQL queries
SELECT users.id, users.fname, users.lname, users.email, users.created_at, rank_email, rank_fname, rank_lname, similarity FROM users, to_tsvector(users.email || users.fname || users.lname) document, to_tsquery(@search_term::TEXT) query, NULLIF(ts_rank(to_tsvector(users.email), query), 0) rank_email, NULLIF(ts_rank(to_tsvector(users.fname), query), 0) rank_fname, NULLIF(ts_rank(to_tsvector(users.lname), query), 0) rank_lname, SIMILARITY(@search_term::TEXT, users.email || users.fname || users.lname) similarity WHERE query @@ document OR similarity > 0 ORDER BY rank_email, rank_lname, rank_fname, similarity DESC NULLS LAST;
Configuration
version: "2" sql: - schema: "migrations" queries: "queries" engine: "postgresql" gen: go: package: "orm" out: "orm" sql_package: "pgx/v4"
Playground URL
https://play.sqlc.dev/p/3935699fa944c07c82d9e0c5cfdd84e95ffd315c62e09a3801bf9209d5f29e81
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go