Skip to content

Commit

Permalink
feat(mysql): Support json.RawMessage for LOAD DATA INFILE (#3099)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jille committed Mar 28, 2024
1 parent ea9f7ed commit d227d5f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func convertRowsFor{{.MethodName}}(w *io.PipeWriter, {{.Arg.SlicePair}}) {
{{- range $arg.CopyFromMySQLFields}}
{{- if eq .Type "string"}}
e.AppendString({{if eq (len $arg.CopyFromMySQLFields) 1}}row{{else}}row.{{.Name}}{{end}})
{{- else if eq .Type "[]byte"}}
{{- else if or (eq .Type "[]byte") (eq .Type "json.RawMessage")}}
e.AppendBytes({{if eq (len $arg.CopyFromMySQLFields) 1}}row{{else}}row.{{.Name}}{{end}})
{{- else}}
e.AppendValue({{if eq (len $arg.CopyFromMySQLFields) 1}}row{{else}}row.{{.Name}}{{end}})
Expand Down
51 changes: 51 additions & 0 deletions internal/endtoend/testdata/json/mysql/go/copyfrom.go

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

10 changes: 10 additions & 0 deletions internal/endtoend/testdata/json/mysql/go/query.sql.go

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

3 changes: 3 additions & 0 deletions internal/endtoend/testdata/json/mysql/query.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
-- name: SelectFoo :exec
SELECT * FROM foo;

-- name: BulkInsert :copyfrom
INSERT INTO foo (a, b) VALUES (?, ?);
1 change: 1 addition & 0 deletions internal/endtoend/testdata/json/mysql/sqlc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
"path": "go",
"engine": "mysql",
"sql_driver": "github.com/go-sql-driver/mysql",
"name": "querytest",
"schema": "schema.sql",
"queries": "query.sql"
Expand Down

0 comments on commit d227d5f

Please sign in to comment.