Skip to content

Commit d4d48ea

Browse files
authored
fix(postgresql): Remove extra comment newline (#1395)
* fix(postgresql): Remove extra comment newline
1 parent 58b0b65 commit d4d48ea

File tree

6 files changed

+162
-4
lines changed

6 files changed

+162
-4
lines changed

internal/codegen/golang/templates/pgx/queryCode.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}}) ({{.Ret.De
4343
{{- if $.EmitMethodsWithDBArgument}}
4444
func (q *Queries) {{.MethodName}}(ctx context.Context, db DBTX, {{.Arg.Pair}}) ([]{{.Ret.DefineType}}, error) {
4545
rows, err := db.Query(ctx, {{.ConstantName}}, {{.Arg.Params}})
46-
{{- else}}
46+
{{- else -}}
4747
func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}}) ([]{{.Ret.DefineType}}, error) {
4848
rows, err := q.db.Query(ctx, {{.ConstantName}}, {{.Arg.Params}})
4949
{{- end}}
@@ -76,7 +76,7 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}}) ([]{{.Ret.
7676
{{- if $.EmitMethodsWithDBArgument}}
7777
func (q *Queries) {{.MethodName}}(ctx context.Context, db DBTX, {{.Arg.Pair}}) error {
7878
_, err := db.Exec(ctx, {{.ConstantName}}, {{.Arg.Params}})
79-
{{- else}}
79+
{{- else -}}
8080
func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}}) error {
8181
_, err := q.db.Exec(ctx, {{.ConstantName}}, {{.Arg.Params}})
8282
{{- end}}
@@ -104,10 +104,10 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}}) (int64, er
104104
{{if eq .Cmd ":execresult"}}
105105
{{range .Comments}}//{{.}}
106106
{{end -}}
107-
{{if $.EmitMethodsWithDBArgument}}
107+
{{- if $.EmitMethodsWithDBArgument}}
108108
func (q *Queries) {{.MethodName}}(ctx context.Context, db DBTX, {{.Arg.Pair}}) (pgconn.CommandTag, error) {
109109
return db.Exec(ctx, {{.ConstantName}}, {{.Arg.Params}})
110-
{{else}}
110+
{{- else -}}
111111
func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}}) (pgconn.CommandTag, error) {
112112
return q.db.Exec(ctx, {{.ConstantName}}, {{.Arg.Params}})
113113
{{- end}}

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

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

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

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CREATE TABLE foo (
2+
bar text
3+
);
4+
5+
-- name: ManyFoo :many
6+
-- This function returns a list of Foos
7+
SELECT * FROM foo;
8+
9+
-- name: OneFoo :one
10+
-- This function returns one Foo
11+
SELECT * FROM foo;
12+
13+
-- name: ExecFoo :exec
14+
-- This function creates a Foo via :exec
15+
INSERT INTO foo (bar) VALUES ("bar");
16+
17+
-- name: ExecRowFoo :execrows
18+
-- This function creates a Foo via :execrows
19+
INSERT INTO foo (bar) VALUES ("bar");
20+
21+
-- name: ExecResultFoo :execresult
22+
-- This function creates a Foo via :execresult
23+
INSERT INTO foo (bar) VALUES ("bar");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "1",
3+
"packages": [
4+
{
5+
"path": "go",
6+
"name": "querytest",
7+
"engine": "postgresql",
8+
"schema": "query.sql",
9+
"queries": "query.sql",
10+
"sql_package": "pgx/v4"
11+
}
12+
]
13+
}
14+

0 commit comments

Comments
 (0)