Skip to content

Commit 9dba8dc

Browse files
authored
feat(sqlite) add support subquery and table function (#1771)
1 parent 1c55cb0 commit 9dba8dc

File tree

21 files changed

+563
-16
lines changed

21 files changed

+563
-16
lines changed

internal/endtoend/testdata/subquery_calculated_column/sqlite/go/db.go

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

internal/endtoend/testdata/subquery_calculated_column/sqlite/go/models.go

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

internal/endtoend/testdata/subquery_calculated_column/sqlite/go/query.sql.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE TABLE foo (a int, b int);
2+
3+
-- name: SubqueryCalcColumn :many
4+
SELECT sum FROM (SELECT a + b AS sum FROM foo) AS f;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "1",
3+
"packages": [
4+
{
5+
"path": "go",
6+
"engine": "sqlite",
7+
"name": "querytest",
8+
"schema": "query.sql",
9+
"queries": "query.sql"
10+
}
11+
]
12+
}

internal/endtoend/testdata/table_function/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/table_function/postgresql/pgx/go/models.go

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

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

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CREATE TABLE transactions (
2+
id BIGSERIAL PRIMARY KEY,
3+
uri text NOT NULL,
4+
program_id text NOT NULL,
5+
data text NOT NULL
6+
);
7+
8+
/* name: GetTransaction :many */
9+
SELECT
10+
json_extract(transactions.data, '$.transaction.signatures[0]'),
11+
json_group_array(instructions.value)
12+
FROM
13+
transactions,
14+
json_each(json_extract(transactions.data, '$.transaction.message.instructions')) AS instructions
15+
WHERE
16+
transactions.program_id = $1
17+
AND json_extract(transactions.data, '$.transaction.signatures[0]') > $2
18+
AND json_extract(json_extract(transactions.data, '$.transaction.message.accountKeys'), '$[' || json_extract(instructions.value, '$.programIdIndex') || ']') = transactions.program_id
19+
GROUP BY transactions.id
20+
LIMIT $3;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "1",
3+
"packages": [
4+
{
5+
"path": "go",
6+
"engine": "postgresql",
7+
"sql_package": "pgx/v4",
8+
"name": "querytest",
9+
"schema": "query.sql",
10+
"queries": "query.sql"
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)