Skip to content

Commit 548aadd

Browse files
committed
Bunch of tests + some convert fixes
1 parent d668dde commit 548aadd

File tree

246 files changed

+4013
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+4013
-14
lines changed

internal/codegen/golang/templates/ydb-go-sdk/interfaceCode.tmpl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
{{- $dbtxParam := .EmitMethodsWithDBArgument -}}
44
{{- range .GoQueries}}
55
{{- if and (eq .Cmd ":one") ($dbtxParam) }}
6-
{{range .Comments}}//{{.}}
7-
{{end -}}
6+
{{- range .Comments}}//{{.}}
7+
{{- end}}
88
{{.MethodName}}(ctx context.Context, db DBTX, {{if not .Arg.IsEmpty}}{{.Arg.Pair}}, {{end}}opts ...query.ExecuteOption) ({{.Ret.DefineType}}, error)
99
{{- else if eq .Cmd ":one"}}
10-
{{range .Comments}}//{{.}}
11-
{{end -}}
10+
{{- range .Comments}}//{{.}}
11+
{{- end}}
1212
{{.MethodName}}(ctx context.Context, {{if not .Arg.IsEmpty}}{{.Arg.Pair}}, {{end}}opts ...query.ExecuteOption) ({{.Ret.DefineType}}, error)
1313
{{- end}}
1414
{{- if and (eq .Cmd ":many") ($dbtxParam) }}
15-
{{range .Comments}}//{{.}}
16-
{{end -}}
15+
{{- range .Comments}}//{{.}}
16+
{{- end}}
1717
{{.MethodName}}(ctx context.Context, db DBTX, {{if not .Arg.IsEmpty}}{{.Arg.Pair}}, {{end}}opts ...query.ExecuteOption) ([]{{.Ret.DefineType}}, error)
1818
{{- else if eq .Cmd ":many"}}
1919
{{range .Comments}}//{{.}}
2020
{{end -}}
2121
{{.MethodName}}(ctx context.Context, {{if not .Arg.IsEmpty}}{{.Arg.Pair}}, {{end}}opts ...query.ExecuteOption) ([]{{.Ret.DefineType}}, error)
2222
{{- end}}
2323
{{- if and (eq .Cmd ":exec") ($dbtxParam) }}
24-
{{range .Comments}}//{{.}}
25-
{{end -}}
24+
{{- range .Comments}}//{{.}}
25+
{{- end}}
2626
{{.MethodName}}(ctx context.Context, db DBTX, {{if not .Arg.IsEmpty}}{{.Arg.Pair}}, {{end}}opts ...query.ExecuteOption) error
2727
{{- else if eq .Cmd ":exec"}}
28-
{{range .Comments}}//{{.}}
29-
{{end -}}
28+
{{- range .Comments}}//{{.}}
29+
{{- end}}
3030
{{.MethodName}}(ctx context.Context, {{if not .Arg.IsEmpty}}{{.Arg.Pair}}, {{end}}opts ...query.ExecuteOption) error
3131
{{- end}}
3232
{{- end}}

internal/codegen/golang/ydb_type.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,37 @@ func YDBType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.Col
7272
return "*int64"
7373

7474
case "uint8":
75+
if notNull {
76+
return "uint8"
77+
}
7578
if emitPointersForNull {
7679
return "*uint8"
7780
}
78-
return "uint8"
81+
return "*uint8"
7982
case "uint16":
83+
if notNull {
84+
return "uint16"
85+
}
8086
if emitPointersForNull {
8187
return "*uint16"
8288
}
83-
return "uint16"
89+
return "*uint16"
8490
case "uint32":
91+
if notNull {
92+
return "uint32"
93+
}
8594
if emitPointersForNull {
8695
return "*uint32"
8796
}
88-
return "uint32"
97+
return "*uint32"
8998
case "uint64":
99+
if notNull {
100+
return "uint64"
101+
}
90102
if emitPointersForNull {
91103
return "*uint64"
92104
}
93-
return "uint64"
105+
return "*uint64"
94106

95107
case "float":
96108
if notNull {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
CREATE TABLE foo (bar Utf8, PRIMARY KEY (bar));
2+
3+

internal/endtoend/testdata/comment_syntax/ydb/stdlib/sqlc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
}
1111
]
1212
}
13+
14+

internal/endtoend/testdata/comment_syntax/ydb/ydb-go-sdk/query.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ SELECT * FROM foo LIMIT 1;
33

44
/* name: SlashStar :one */
55
SELECT * FROM foo LIMIT 1;
6+
7+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
CREATE TABLE foo (bar Text, PRIMARY KEY (bar));
2+
3+

internal/endtoend/testdata/comment_syntax/ydb/ydb-go-sdk/sqlc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
}
1212
]
1313
}
14+
15+

internal/endtoend/testdata/comparisons/ydb/stdlib/query.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ SELECT COUNT(*) <> 0 FROM bar;
1818

1919
-- name: Equal :many
2020
SELECT COUNT(*) = 0 FROM bar;
21+
22+

internal/endtoend/testdata/comparisons/ydb/stdlib/schema.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
-- https://www.postgresql.org/docs/current/functions-comparison.html
33

44
CREATE TABLE bar (id Serial NOT NULL, PRIMARY KEY (id));
5+
6+

internal/endtoend/testdata/comparisons/ydb/stdlib/sqlc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
}
1111
]
1212
}
13+
14+

0 commit comments

Comments
 (0)