Skip to content

Commit

Permalink
fix(MySQL): Handle null MySQL JSON values (sqlc-dev#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
0n1shi committed Apr 29, 2024
1 parent 811b6b0 commit 62b448a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion internal/codegen/golang/mysql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ func mysqlType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.C
return "sql.NullBool"

case "json":
return "json.RawMessage"
if notNull {
return "json.RawMessage"
}
return "*json.RawMessage"

case "any":
return "interface{}"
Expand Down
2 changes: 1 addition & 1 deletion 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.

2 changes: 1 addition & 1 deletion internal/endtoend/testdata/json/mysql/go/models.go

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

2 changes: 1 addition & 1 deletion 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.

0 comments on commit 62b448a

Please sign in to comment.