diff --git a/internal/codegen/golang/reserved.go b/internal/codegen/golang/reserved.go index fee711c57b..0461c4a2de 100644 --- a/internal/codegen/golang/reserved.go +++ b/internal/codegen/golang/reserved.go @@ -59,6 +59,8 @@ func IsReserved(s string) bool { return true case "var": return true + case "q": + return true default: return false } diff --git a/internal/endtoend/testdata/params_go_keywords/postgresql/go/models.go b/internal/endtoend/testdata/params_go_keywords/postgresql/go/models.go index e6e549432d..1c6b61b891 100644 --- a/internal/endtoend/testdata/params_go_keywords/postgresql/go/models.go +++ b/internal/endtoend/testdata/params_go_keywords/postgresql/go/models.go @@ -34,4 +34,5 @@ type GoKeyword struct { Import pgtype.Text Return pgtype.Text Var pgtype.Text + Q pgtype.Text } diff --git a/internal/endtoend/testdata/params_go_keywords/postgresql/go/query.sql.go b/internal/endtoend/testdata/params_go_keywords/postgresql/go/query.sql.go index ba0ad88064..8fa0810d65 100644 --- a/internal/endtoend/testdata/params_go_keywords/postgresql/go/query.sql.go +++ b/internal/endtoend/testdata/params_go_keywords/postgresql/go/query.sql.go @@ -173,6 +173,15 @@ func (q *Queries) KeywordPackage(ctx context.Context, package_ string) error { return err } +const keywordQ = `-- name: KeywordQ :exec +SELECT $1::text +` + +func (q *Queries) KeywordQ(ctx context.Context, q_ string) error { + _, err := q.db.Exec(ctx, keywordQ, q_) + return err +} + const keywordRange = `-- name: KeywordRange :exec SELECT $1::text ` @@ -434,6 +443,17 @@ func (q *Queries) SelectPackage(ctx context.Context) (pgtype.Text, error) { return package_, err } +const selectQ = `-- name: SelectQ :one +SELECT "q" FROM go_keywords +` + +func (q *Queries) SelectQ(ctx context.Context) (pgtype.Text, error) { + row := q.db.QueryRow(ctx, selectQ) + var q_ pgtype.Text + err := row.Scan(&q_) + return q_, err +} + const selectRange = `-- name: SelectRange :one SELECT "range" FROM go_keywords ` diff --git a/internal/endtoend/testdata/params_go_keywords/postgresql/query.sql b/internal/endtoend/testdata/params_go_keywords/postgresql/query.sql index 70796e4e3e..bc45b1166f 100644 --- a/internal/endtoend/testdata/params_go_keywords/postgresql/query.sql +++ b/internal/endtoend/testdata/params_go_keywords/postgresql/query.sql @@ -73,6 +73,9 @@ SELECT sqlc.arg('return')::text; -- name: KeywordVar :exec SELECT sqlc.arg('var')::text; +-- name: KeywordQ :exec +SELECT sqlc.arg('q')::text; + -- name: SelectBreak :one SELECT "break" FROM go_keywords; @@ -147,3 +150,6 @@ SELECT "return" FROM go_keywords; -- name: SelectVar :one SELECT "var" FROM go_keywords; + +-- name: SelectQ :one +SELECT "q" FROM go_keywords; diff --git a/internal/endtoend/testdata/params_go_keywords/postgresql/schema.sql b/internal/endtoend/testdata/params_go_keywords/postgresql/schema.sql index 11a04beef6..100be50211 100644 --- a/internal/endtoend/testdata/params_go_keywords/postgresql/schema.sql +++ b/internal/endtoend/testdata/params_go_keywords/postgresql/schema.sql @@ -23,5 +23,6 @@ CREATE TABLE go_keywords ( "for" TEXT, "import" TEXT, "return" TEXT, - "var" TEXT + "var" TEXT, + "q" TEXT );