FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(golang): escape generated enum values (fix #4448) by sjh9714 · Pull Request #4449 · sqlc-dev/sqlc · GitHub

/ sqlc Public
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .go  (3) .json  (1) .sql  (2) .tmpl  (1) .yaml  (1) All 5 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
      • exec.json
        • db.go
        • models.go
        • query.sql.go
      • query.sql
      • schema.sql
      • sqlc.yaml
2 changes: 1 addition & 1 deletion internal/codegen/golang/templates/template.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type {{.Name}} string

const (
{{- range .Constants}}
{{.Name}} {{.Type}} = "{{.Value}}"
{{.Name}} {{.Type}} = {{printf "%q" .Value}}
{{- end}}
)

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"contexts": ["base"]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- name: GetUser :one
SELECT id, role, payload FROM users WHERE id = $1;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TYPE injection AS ENUM (
'safe_value',
'injected" + "arbitrary_go_code" + "'
);

CREATE TYPE user_role AS ENUM (
'admin',
'user\nadmin'
);

CREATE TABLE users (
id SERIAL PRIMARY KEY,
role user_role NOT NULL,
payload injection NOT NULL
);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "2"
sql:
- engine: postgresql
schema: "schema.sql"
queries: "query.sql"
gen:
go:
package: "querytest"
out: "go"
Loading

Back | FazBrowse Home | New Git URL