Skip to content

Commit

Permalink
fix(mysql)!: Generate unsigned param (#2522)
Browse files Browse the repository at this point in the history
A fix to the original change (#1746) that added support for unsigned integers. While this is a breaking change, it's impact should be smaller than the previous change.

* fix missing unsigned param
* add end-to-end test for unsigned_params
  • Loading branch information
hiroebe committed Jul 25, 2023
1 parent b9c3af4 commit e3c657d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/compiler/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ func (comp *Compiler) resolveCatalogRefs(qc *QueryCatalog, rvs []*ast.RangeVar,
OriginalName: c.Name,
DataType: dataType(&c.Type),
NotNull: p.NotNull(),
Unsigned: c.IsUnsigned,
IsArray: c.IsArray,
Table: &ast.TableName{Schema: schema, Name: rel},
Length: c.Length,
Expand Down

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

31 changes: 31 additions & 0 deletions internal/endtoend/testdata/unsigned_params/mysql/go/db.go

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

11 changes: 11 additions & 0 deletions internal/endtoend/testdata/unsigned_params/mysql/go/models.go

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

19 changes: 19 additions & 0 deletions internal/endtoend/testdata/unsigned_params/mysql/go/query.sql.go

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

4 changes: 4 additions & 0 deletions internal/endtoend/testdata/unsigned_params/mysql/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE foo (id INT UNSIGNED NOT NULL);

-- name: CreateFoo :exec
INSERT INTO foo (id) VALUES (?);
12 changes: 12 additions & 0 deletions internal/endtoend/testdata/unsigned_params/mysql/sqlc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "1",
"packages": [
{
"path": "go",
"engine": "mysql",
"name": "querytest",
"schema": "query.sql",
"queries": "query.sql"
}
]
}

0 comments on commit e3c657d

Please sign in to comment.