Skip to content

Commit

Permalink
Merge pull request #2 from mailru/fixed_issue_1
Browse files Browse the repository at this point in the history
Fixed parse result for query WITH TOTALS
  • Loading branch information
bgaifullin committed Jul 18, 2017
2 parents 1241723 + 64464fb commit 463ccdb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func (s *connSuite) TestQuery() {
[][]interface{}{{int64(-1), uint64(1), float64(1), "1", []int16{1},
parseDate("2011-03-06"), parseDateTime("2011-03-06 06:20:00"), "one"}},
},
{
"SELECT i64, count() FROM data WHERE i64<0 GROUP BY i64 WITH TOTALS ORDER BY i64",
nil,
[][]interface{}{{int64(-3), int64(1)}, {int64(-2), int64(1)}, {int64(-1), int64(1)}, {int64(0), int64(3)}},
},
}
for _, tc := range testCases {
rows, err := s.conn.Query(tc.query, tc.args...)
Expand Down
5 changes: 5 additions & 0 deletions rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func (r *textRows) Next(dest []driver.Value) error {
k++
i = j + 1
case '\n':
if j == 0 {
// totals are separated by empty line
i = j + 1
continue
}
dest[k], err = r.decode.Decode(r.types[k], r.data[i:j])
r.data = r.data[j+1:]
return err
Expand Down

0 comments on commit 463ccdb

Please sign in to comment.