diff --git a/sqliteclidriver/sqliteclidriver.go b/sqliteclidriver/sqliteclidriver.go index 1664a56..7e17193 100644 --- a/sqliteclidriver/sqliteclidriver.go +++ b/sqliteclidriver/sqliteclidriver.go @@ -267,7 +267,7 @@ func (s *SCStmt) Query(args []driver.Value) (driver.Rows, error) { // We expect some kind of thing on stdout // If something happens on stderr, or to the process, pr will read an error - ret := []map[string]any{} + ret := []OrderedKV{} decoder := json.NewDecoder(pr) err = decoder.Decode(&ret) if err != nil { @@ -276,13 +276,11 @@ func (s *SCStmt) Query(args []driver.Value) (driver.Rows, error) { // Check if this was the data or the sentinel wasSentinel := false - if len(ret) > 0 { - if val, ok := ret[0][sentinelKey]; ok { - if check, ok := val.(string); ok && check == sentinelVal { - // It was the sentinel - wasSentinel = true - // Nothing more to parse - } + if len(ret) > 0 && len(ret[0]) > 0 && ret[0][0].Key == sentinelKey { + if check, ok := ret[0][0].Value.(string); ok && check == sentinelVal { + // It was the sentinel + wasSentinel = true + // Nothing more to parse } } @@ -312,8 +310,8 @@ func (s *SCStmt) Query(args []driver.Value) (driver.Rows, error) { var columnNames []string if len(ret) > 0 { - for k, _ := range ret[0] { - columnNames = append(columnNames, k) + for _, cell := range ret[0] { + columnNames = append(columnNames, cell.Key) } } @@ -347,7 +345,7 @@ var _ driver.Result = &SCResult{} // interface assertion type SCRows struct { idx int columns []string - data []map[string]any + data []OrderedKV } func (r *SCRows) Columns() []string { @@ -370,12 +368,9 @@ func (r *SCRows) Next(dest []driver.Value) error { } for i := 0; i < len(dest); i++ { - cell, ok := r.data[r.idx][r.columns[i]] - if !ok { - return fmt.Errorf("Result row %d is missing column #%d %q, unexpected", r.idx, i, r.columns[i]) - } + cell := r.data[r.idx][i] - dest[i] = cell + dest[i] = cell.Value } r.idx++