Skip to content

Commit 65e00e6

Browse files
tests: added sql_syntax_calling_funcs to pgx
1 parent 090a95d commit 65e00e6

File tree

10 files changed

+151
-0
lines changed

10 files changed

+151
-0
lines changed

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

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

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

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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+
"driver": "pgx/v4",
8+
"name": "querytest",
9+
"schema": "query.sql",
10+
"queries": "query.sql"
11+
}
12+
]
13+
}

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

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- https://www.postgresql.org/docs/current/sql-syntax-calling-funcs.html
2+
CREATE FUNCTION concat_lower_or_upper(a text, b text, uppercase boolean DEFAULT false)
3+
RETURNS text
4+
AS
5+
$$
6+
SELECT CASE
7+
WHEN $3 THEN UPPER($1 || ' ' || $2)
8+
ELSE LOWER($1 || ' ' || $2)
9+
END;
10+
$$
11+
LANGUAGE SQL IMMUTABLE STRICT;
12+
13+
-- name: PositionalNotation :one
14+
SELECT concat_lower_or_upper('Hello', 'World', true);
15+
16+
-- name: PositionalNoDefaault :one
17+
SELECT concat_lower_or_upper('Hello', 'World');
18+
19+
-- name: NamedNotation :one
20+
SELECT concat_lower_or_upper(a => 'Hello', b => 'World');
21+
22+
-- name: NamedAnyOrder :one
23+
SELECT concat_lower_or_upper(a => 'Hello', b => 'World', uppercase => true);
24+
25+
-- name: NamedOtherOrder :one
26+
SELECT concat_lower_or_upper(a => 'Hello', uppercase => true, b => 'World');
27+
28+
-- name: MixedNotation :one
29+
SELECT concat_lower_or_upper('Hello', 'World', uppercase => true);

0 commit comments

Comments
 (0)