Skip to content

Commit 228fd44

Browse files
authored
parser: Set IsArray on joined columns (#139)
1 parent a2c8d09 commit 228fd44

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

internal/dinosql/parser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ func outputColumnRefs(res nodes.ResTarget, tables []core.Table, node nodes.Colum
748748
Name: cname,
749749
DataType: c.DataType,
750750
NotNull: c.NotNull,
751+
IsArray: c.IsArray,
751752
})
752753
}
753754
}

internal/dinosql/query_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,21 @@ func TestQueries(t *testing.T) {
722722
},
723723
},
724724
},
725+
{
726+
"join-text-array",
727+
`
728+
CREATE TABLE foo (id text not null, bar text not null);
729+
CREATE TABLE bar (id text not null, info text[] not null);
730+
SELECT bar.info
731+
FROM foo
732+
JOIN bar ON foo.bar = bar.id;
733+
`,
734+
Query{
735+
Columns: []core.Column{
736+
{Name: "info", DataType: "text", NotNull: true, IsArray: true, Table: public("bar")},
737+
},
738+
},
739+
},
725740
} {
726741
test := tc
727742
t.Run(test.name, func(t *testing.T) {

0 commit comments

Comments
 (0)