Skip to content

Commit fc8c932

Browse files
1NepuNep1Viktor Pentyukhov
authored andcommitted
Added examples for funcs codegen
1 parent 0293f6a commit fc8c932

File tree

5 files changed

+67
-16
lines changed

5 files changed

+67
-16
lines changed

examples/authors/sqlc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ sql:
5151
go:
5252
package: authors
5353
out: ydb
54+
emit_json_tags: true
5455

5556

5657
rules:

examples/authors/ydb/models.go

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

examples/authors/ydb/query.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ WHERE name = $p0;
1313
SELECT * FROM authors
1414
WHERE bio IS NULL;
1515

16+
-- name: Count :one
17+
SELECT COUNT(*) FROM authors;
18+
19+
-- name: COALESCE :many
20+
SELECT id, name, COALESCE(bio, 'Null value!') FROM authors;
21+
1622
-- name: CreateOrUpdateAuthor :execresult
1723
UPSERT INTO authors (id, name, bio) VALUES ($p0, $p1, $p2);
1824

examples/authors/ydb/query.sql.go

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

examples/authors/ydb/schema.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE TABLE authors (
2-
id Uint64,
3-
name Utf8 NOT NULL,
4-
bio Utf8,
5-
PRIMARY KEY (id)
2+
id Uint64,
3+
name Utf8 NOT NULL,
4+
bio Utf8,
5+
PRIMARY KEY (id)
66
);

0 commit comments

Comments
 (0)