Skip to content

Commit

Permalink
Move unmarshalling of columns to initColumns method
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesmet authored and losipiuk committed Aug 31, 2022
1 parent 147fe28 commit 9b9640d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions trino/trino.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,12 +1045,6 @@ func (qr *driverRows) fetch(allowEOF bool) error {
}
}
if qr.columns == nil && len(qresp.Columns) > 0 {
for i := range qresp.Columns {
err = unmarshalArguments(&(qresp.Columns[i].TypeSignature))
if err != nil {
return fmt.Errorf("error decoding column type signature: %w", err)
}
}
err = qr.initColumns(&qresp)
if err != nil {
return err
Expand Down Expand Up @@ -1116,9 +1110,15 @@ func unmarshalArguments(signature *typeSignature) error {
}

func (qr *driverRows) initColumns(qresp *queryResponse) error {
var err error
for i := range qresp.Columns {
err = unmarshalArguments(&(qresp.Columns[i].TypeSignature))
if err != nil {
return fmt.Errorf("error decoding column type signature: %w", err)
}
}
qr.columns = make([]string, len(qresp.Columns))
qr.coltype = make([]*typeConverter, len(qresp.Columns))
var err error
for i, col := range qresp.Columns {
qr.columns[i] = col.Name
qr.coltype[i], err = newTypeConverter(col.Type, col.TypeSignature)
Expand Down

0 comments on commit 9b9640d

Please sign in to comment.