Skip to content

Commit 749d875

Browse files
authored
golang: Generate correct types for int2 and int8 (#579)
* golang: Generate correct types for int2 and int8 * endtoend: Update generated code for datatype test
1 parent 48a07a7 commit 749d875

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

internal/codegen/golang/postgresql_type.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ func postgresType(r *compiler.Result, col *compiler.Column, settings config.Comb
3434
}
3535
return "sql.NullInt32"
3636

37-
case "bigint", "pg_catalog.int8":
37+
case "bigint", "int8", "pg_catalog.int8":
3838
if notNull {
3939
return "int64"
4040
}
4141
return "sql.NullInt64"
4242

43-
case "smallint", "pg_catalog.int2":
43+
case "smallint", "int2", "pg_catalog.int2":
4444
return "int16"
4545

4646
case "float", "double precision", "pg_catalog.float8":

internal/endtoend/testdata/datatype/go/models.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/datatype/sql/numeric.sql

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ CREATE TABLE dt_numeric (
1212
-- TODO: this maps incorrectly to int16, not NullInt16
1313
h smallserial,
1414
i serial,
15-
j bigserial
15+
j bigserial,
16+
-- TODO: this maps incorrectly to int16, not NullInt16
17+
k int2,
18+
l int4,
19+
m int8
1620
);
1721

1822
CREATE TABLE dt_numeric_not_null (
@@ -25,5 +29,8 @@ CREATE TABLE dt_numeric_not_null (
2529
g double precision NOT NULL,
2630
h smallserial NOT NULL,
2731
i serial NOT NULL,
28-
j bigserial NOT NULL
32+
j bigserial NOT NULL,
33+
k int2 NOT NULL,
34+
l int4 NOT NULL,
35+
m int8 NOT NULL
2936
);

0 commit comments

Comments
 (0)