Skip to content

Commit

Permalink
Support row types
Browse files Browse the repository at this point in the history
  • Loading branch information
nineinchnick authored and losipiuk committed Jul 11, 2022
1 parent b978ada commit 9155c49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions trino/trino.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,11 @@ func (c *typeConverter) ConvertValue(v interface{}) (driver.Value, error) {
return nil, err
}
return v, nil
case "row":
if err := validateSlice(v); err != nil {
return nil, err
}
return v, nil
default:
return nil, fmt.Errorf("type not supported: %q", c.typeName)
}
Expand Down
16 changes: 16 additions & 0 deletions trino/trino_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,22 @@ func TestTypeConversion(t *testing.T) {
ResponseUnmarshalledSample: nil,
ExpectedGoValue: nil,
},
{
// rows return data as-is for slice scanners
DataType: "row(int, varchar(1), timestamp, array(varchar(1)))",
ResponseUnmarshalledSample: []interface{}{
json.Number("1"),
"a",
"2017-07-10 01:02:03.000 UTC",
[]interface{}{"b"},
},
ExpectedGoValue: []interface{}{
json.Number("1"),
"a",
"2017-07-10 01:02:03.000 UTC",
[]interface{}{"b"},
},
},
}

for _, tc := range testcases {
Expand Down

0 comments on commit 9155c49

Please sign in to comment.