Skip to content

Commit cbc15c4

Browse files
committed
test: Add case for #2187
1 parent fb2d81b commit cbc15c4

File tree

8 files changed

+180
-0
lines changed

8 files changed

+180
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO
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/cte_recursive_union/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/cte_recursive_union/postgresql/pgx/go/models.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/cte_recursive_union/postgresql/pgx/go/query.sql.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- name: ListCaseIntentHistory :many
2+
WITH RECURSIVE descendants AS
3+
( SELECT case_intent_parent_id AS parent, case_intent_id AS child, 1 AS lvl
4+
FROM case_intent_parent_join
5+
UNION ALL
6+
SELECT d.parent as parent, p.case_intent_id as child, d.lvl + 1 as lvl
7+
FROM descendants d
8+
JOIN case_intent_parent_join p
9+
ON d.child = p.case_intent_parent_id
10+
)
11+
select distinct child, 'child' group_
12+
from descendants
13+
where parent = @case_intent_id
14+
union
15+
select distinct parent, 'parent' group_
16+
from descendants
17+
where child = @case_intent_id
18+
ORDER BY child;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CREATE TABLE case_intent_version
2+
(
3+
version_id SERIAL NOT NULL PRIMARY KEY,
4+
reviewer TEXT NOT NULL,
5+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
6+
);
7+
CREATE TABLE case_intent
8+
(
9+
id SERIAL NOT NULL PRIMARY KEY,
10+
case_intent_string TEXT NOT NULL,
11+
description TEXT NOT NULL,
12+
author TEXT NOT NULL
13+
);
14+
CREATE TABLE case_intent_parent_join
15+
(
16+
case_intent_id BIGINT NOT NULL,
17+
case_intent_parent_id BIGINT NOT NULL,
18+
constraint fk_case_intent_id foreign key (case_intent_id) references case_intent(id),
19+
constraint fk_case_intent_parent_id foreign key (case_intent_parent_id) references case_intent(id)
20+
);
21+
CREATE TABLE case_intent_version_join
22+
(
23+
case_intent_id BIGINT NOT NULL,
24+
case_intent_version_id INT NOT NULL,
25+
constraint fk_case_intent_id foreign key (case_intent_id) references case_intent(id),
26+
constraint fk_case_intent_version_id foreign key (case_intent_version_id) references case_intent_version(version_id)
27+
);
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)