Skip to content

Commit e1d5978

Browse files
eullerpereira94kyleconroy
authored andcommitted
support to bytea added, passed the test in gen_test.go, not sure if it will work in all situations, please review (#109)
1 parent 6ad1dd9 commit e1d5978

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

internal/dinosql/gen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@ func (r Result) goInnerType(columnType string, notNull bool) string {
489489
case "jsonb":
490490
return "json.RawMessage"
491491

492+
case "bytea", "pg_catalog.bytea":
493+
return "[]byte"
494+
492495
case "pg_catalog.timestamp", "pg_catalog.timestamptz":
493496
if notNull {
494497
return "time.Time"

internal/dinosql/gen_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ func TestColumnsToStruct(t *testing.T) {
3030
NotNull: true,
3131
IsArray: true,
3232
},
33+
{
34+
Name: "byte_seq",
35+
DataType: "bytea",
36+
NotNull: true,
37+
},
3338
}
3439

3540
r := Result{}
@@ -41,6 +46,7 @@ func TestColumnsToStruct(t *testing.T) {
4146
{Name: "Count", Type: "int64", Tags: map[string]string{"json:": "count"}},
4247
{Name: "Count_2", Type: "int64", Tags: map[string]string{"json:": "count_2"}},
4348
{Name: "Tags", Type: "[]string", Tags: map[string]string{"json:": "tags"}},
49+
{Name: "ByteSeq", Type: "[]byte", Tags: map[string]string{"json:": "byte_seq"}},
4450
},
4551
}
4652
if diff := cmp.Diff(expected, actual); diff != "" {

0 commit comments

Comments
 (0)