-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/sqlc-dev/sqlc/issues/1739 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"contexts": ["managed-db"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- name: GetUsers :many | ||
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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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) | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: "2" | ||
sql: | ||
- engine: "postgresql" | ||
schema: "schema.sql" | ||
queries: "query.sql" | ||
gen: | ||
go: | ||
package: "querytest" | ||
out: "go" | ||
sql_package: "database/sql" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/sqlc-dev/sqlc/pull/2639 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"contexts": ["managed-db"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- name: Subquery :many | ||
SELECT | ||
a, | ||
name, | ||
(SELECT alias FROM bar WHERE bar.a=foo.a AND alias = $1 ORDER BY bar.a DESC limit 1) as alias | ||
FROM FOO WHERE a = $2; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CREATE TABLE foo (a int not null, name text); | ||
CREATE TABLE bar (a int not null, alias text); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: "2" | ||
sql: | ||
- engine: "postgresql" | ||
schema: "schema.sql" | ||
queries: "query.sql" | ||
gen: | ||
go: | ||
package: "querytest" | ||
out: "go" | ||
sql_package: "database/sql" |