Skip to content

Commit 83a925d

Browse files
committed
test: Add case for #1990
1 parent 7bf9512 commit 83a925d

File tree

8 files changed

+140
-0
lines changed

8 files changed

+140
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/sqlc-dev/sqlc/issues/1990
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"contexts": ["managed-db"]
3+
}

internal/endtoend/testdata/select_subquery_alias/postgresql/pgx/go/db.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/select_subquery_alias/postgresql/pgx/go/models.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/select_subquery_alias/postgresql/pgx/go/query.sql.go

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- name: FindWallets :many
2+
select id, address, balance, total_balance from
3+
(
4+
select id, address, balance,
5+
sum(balance) over (order by balance desc rows between unbounded preceding and current row) as total_balance,
6+
sum(balance) over (order by balance desc rows between unbounded preceding and current row) - balance as last_balance
7+
from wallets
8+
where type=$1
9+
) amounts
10+
where amounts.last_balance < $2;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE IF NOT EXISTS wallets
2+
(
3+
id BIGSERIAL PRIMARY KEY,
4+
address VARCHAR(44) NOT NULL,
5+
type VARCHAR(44) NOT NULL,
6+
balance DECIMAL(32, 18) NULL
7+
);
Lines changed: 10 additions & 0 deletions
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: "pgx/v5"

0 commit comments

Comments
 (0)