Skip to content

Commit 5123a83

Browse files
author
Viktor Pentyukhov
committed
Retries v2.0
1 parent 3691fb3 commit 5123a83

File tree

16 files changed

+391
-394
lines changed

16 files changed

+391
-394
lines changed

examples/authors/ydb/db.go

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

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: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
-- name: ListAuthors :many
2-
SELECT * FROM authors;
3-
4-
-- name: GetAuthor :one
5-
SELECT * FROM authors
6-
WHERE id = $p0;
7-
8-
-- name: GetAuthorsByName :many
9-
SELECT * FROM authors
10-
WHERE name = $p0;
11-
12-
-- name: ListAuthorsWithNullBio :many
13-
SELECT * FROM authors
14-
WHERE bio IS NULL;
15-
161
-- name: CountAuthors :one
2+
-- @ydb-retry-idempotent
173
SELECT COUNT(*) FROM authors;
184

195
-- name: Coalesce :many
206
SELECT id, name, COALESCE(bio, 'Null value!') FROM authors;
217

228
-- name: CreateOrUpdateAuthor :execresult
9+
-- @ydb-with-tx
2310
UPSERT INTO authors (id, name, bio) VALUES ($p0, $p1, $p2);
2411

2512
-- name: CreateOrUpdateAuthorReturningBio :one

examples/authors/ydb/query.sql.go

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

internal/cmd/shim.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cmd
22

33
import (
4+
"strings"
5+
46
"github.com/sqlc-dev/sqlc/internal/compiler"
57
"github.com/sqlc-dev/sqlc/internal/config"
68
"github.com/sqlc-dev/sqlc/internal/config/convert"
@@ -152,11 +154,24 @@ func pluginQueries(r *compiler.Result) []*plugin.Query {
152154
Name: q.InsertIntoTable.Name,
153155
}
154156
}
157+
// Include YDB metadata in comments for codegen access
158+
comments := q.Metadata.Comments
159+
for flag := range q.Metadata.Flags {
160+
if strings.HasPrefix(flag, "@ydb-") {
161+
comments = append(comments, "YDB_FLAG:"+flag)
162+
}
163+
}
164+
for param, value := range q.Metadata.Params {
165+
if strings.HasPrefix(param, "@ydb-") {
166+
comments = append(comments, "YDB_PARAM:"+param+"="+value)
167+
}
168+
}
169+
155170
out = append(out, &plugin.Query{
156171
Name: q.Metadata.Name,
157172
Cmd: q.Metadata.Cmd,
158173
Text: q.SQL,
159-
Comments: q.Metadata.Comments,
174+
Comments: comments,
160175
Columns: columns,
161176
Params: params,
162177
Filename: q.Metadata.Filename,

0 commit comments

Comments
 (0)