From d3dde3e8a2faa09ee99d1185c110b30c7c702dd0 Mon Sep 17 00:00:00 2001 From: Euller do Amaral Pereira Date: Wed, 23 Oct 2019 14:48:19 -0300 Subject: [PATCH] support to bytea added, passed the test in gen_test.go, not sure if it will work in all situations, please review --- internal/dinosql/gen.go | 3 +++ internal/dinosql/gen_test.go | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/internal/dinosql/gen.go b/internal/dinosql/gen.go index c48b877329..b5f862b17b 100644 --- a/internal/dinosql/gen.go +++ b/internal/dinosql/gen.go @@ -489,6 +489,9 @@ func (r Result) goInnerType(columnType string, notNull bool) string { case "jsonb": return "json.RawMessage" + case "bytea", "pg_catalog.bytea": + return "[]byte" + case "pg_catalog.timestamp", "pg_catalog.timestamptz": if notNull { return "time.Time" diff --git a/internal/dinosql/gen_test.go b/internal/dinosql/gen_test.go index 8060432941..da5c756dda 100644 --- a/internal/dinosql/gen_test.go +++ b/internal/dinosql/gen_test.go @@ -30,6 +30,11 @@ func TestColumnsToStruct(t *testing.T) { NotNull: true, IsArray: true, }, + { + Name: "byte_seq", + DataType: "bytea", + NotNull: true, + }, } r := Result{} @@ -41,6 +46,7 @@ func TestColumnsToStruct(t *testing.T) { {Name: "Count", Type: "int64", Tags: map[string]string{"json:": "count"}}, {Name: "Count_2", Type: "int64", Tags: map[string]string{"json:": "count_2"}}, {Name: "Tags", Type: "[]string", Tags: map[string]string{"json:": "tags"}}, + {Name: "ByteSeq", Type: "[]byte", Tags: map[string]string{"json:": "byte_seq"}}, }, } if diff := cmp.Diff(expected, actual); diff != "" {