Skip to content

Commit cbd90ec

Browse files
test: Add more analyzer test cases (sqlc-dev#2866)
* test: Add a test case for sqlc-dev#1739 * test: Add a test case for sqlc-dev#2639
1 parent 795bbc7 commit cbd90ec

File tree

16 files changed

+301
-0
lines changed

16 files changed

+301
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/sqlc-dev/sqlc/issues/1739
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"contexts": ["managed-db"]
3+
}

internal/endtoend/testdata/column_alias/stdlib/go/db.go

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/column_alias/stdlib/go/models.go

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/column_alias/stdlib/go/query.sql.go

+80
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- name: GetUsers :many
2+
SELECT
3+
users.id,
4+
users.fname,
5+
users.lname,
6+
users.email,
7+
users.created_at,
8+
rank_email,
9+
rank_fname,
10+
rank_lname,
11+
similarity
12+
FROM
13+
users,
14+
to_tsvector(users.email || users.fname || users.lname) document,
15+
to_tsquery(@search_term::TEXT) query,
16+
NULLIF(ts_rank(to_tsvector(users.email), query), 0) rank_email,
17+
NULLIF(ts_rank(to_tsvector(users.fname), query), 0) rank_fname,
18+
NULLIF(ts_rank(to_tsvector(users.lname), query), 0) rank_lname,
19+
SIMILARITY(@search_term::TEXT, users.email || users.fname || users.lname) similarity
20+
WHERE query @@ document OR similarity > 0
21+
ORDER BY rank_email, rank_lname, rank_fname, similarity DESC NULLS LAST;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE EXTENSION pg_trgm;
2+
CREATE EXTENSION pgcrypto;
3+
4+
CREATE TABLE users(
5+
id INT GENERATED ALWAYS AS IDENTITY NOT NULL,
6+
fname VARCHAR(100) NOT NULL,
7+
lname VARCHAR(100) NOT NULL,
8+
email VARCHAR(100) NOT NULL UNIQUE,
9+
enc_passwd TEXT NOT NULL,
10+
created_at TIMESTAMP WITH TIME ZONE NOT NULL default (NOW() AT TIME ZONE 'utc'),
11+
PRIMARY KEY(id)
12+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "2"
2+
sql:
3+
- engine: "postgresql"
4+
schema: "schema.sql"
5+
queries: "query.sql"
6+
gen:
7+
go:
8+
package: "querytest"
9+
out: "go"
10+
sql_package: "database/sql"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/sqlc-dev/sqlc/pull/2639
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"contexts": ["managed-db"]
3+
}

internal/endtoend/testdata/select_subquery/postgresql/stdlib/go/db.go

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/select_subquery/postgresql/stdlib/go/models.go

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/select_subquery/postgresql/stdlib/go/query.sql.go

+53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- name: Subquery :many
2+
SELECT
3+
a,
4+
name,
5+
(SELECT alias FROM bar WHERE bar.a=foo.a AND alias = $1 ORDER BY bar.a DESC limit 1) as alias
6+
FROM FOO WHERE a = $2;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE TABLE foo (a int not null, name text);
2+
CREATE TABLE bar (a int not null, alias text);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "2"
2+
sql:
3+
- engine: "postgresql"
4+
schema: "schema.sql"
5+
queries: "query.sql"
6+
gen:
7+
go:
8+
package: "querytest"
9+
out: "go"
10+
sql_package: "database/sql"

0 commit comments

Comments
 (0)