mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Rows accepts a fields param for backward compat.
This commit is contained in:
parent
dc735c17b8
commit
c30f9bc192
2 changed files with 26 additions and 3 deletions
10
executor.go
10
executor.go
|
|
@ -1090,9 +1090,13 @@ func (e *executor) executeGroupByShard(ctx context.Context, index string, c *pql
|
|||
|
||||
func (e *executor) executeRows(ctx context.Context, index string, c *pql.Call, shards []uint64, opt *execOptions) (RowIDs, error) {
|
||||
// Fetch field name from argument.
|
||||
fieldName, ok := c.Args["_field"].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("Rows() field required")
|
||||
// Check "field" first for backwards compatibility
|
||||
var fieldName string
|
||||
var ok bool
|
||||
if fieldName, ok = c.Args["field"].(string); !ok {
|
||||
if fieldName, ok = c.Args["_field"].(string); !ok {
|
||||
return nil, errors.New("Rows() field required")
|
||||
}
|
||||
}
|
||||
if columnID, ok, err := c.UintArg("column"); err != nil {
|
||||
return nil, errors.Wrap(err, "getting column")
|
||||
|
|
|
|||
|
|
@ -3043,6 +3043,13 @@ func TestExecutor_Execute_Rows(t *testing.T) {
|
|||
t.Fatalf("unexpected rows: %+v", rows)
|
||||
}
|
||||
|
||||
// backwards compatibility
|
||||
// TODO: remove at Pilosa 2.0
|
||||
rows = c.Query(t, "i", `Rows(field=general)`).Results[0].(pilosa.RowIdentifiers)
|
||||
if !reflect.DeepEqual(rows, pilosa.RowIdentifiers{Rows: []uint64{10, 11, 12, 13}}) {
|
||||
t.Fatalf("unexpected rows: %+v", rows)
|
||||
}
|
||||
|
||||
rows = c.Query(t, "i", `Rows(general, limit=2)`).Results[0].(pilosa.RowIdentifiers)
|
||||
if !reflect.DeepEqual(rows, pilosa.RowIdentifiers{Rows: []uint64{10, 11}}) {
|
||||
t.Fatalf("unexpected rows: %+v", rows)
|
||||
|
|
@ -3154,10 +3161,22 @@ func TestExecutor_Execute_Rows_Keys(t *testing.T) {
|
|||
q: `Rows(f)`,
|
||||
exp: []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"},
|
||||
},
|
||||
// backwards compatibility
|
||||
// TODO: remove at Pilosa 2.0
|
||||
{
|
||||
q: `Rows(field=f)`,
|
||||
exp: []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"},
|
||||
},
|
||||
{
|
||||
q: `Rows(f, limit=2)`,
|
||||
exp: []string{"0", "1"},
|
||||
},
|
||||
// backwards compatibility
|
||||
// TODO: remove at Pilosa 2.0
|
||||
{
|
||||
q: `Rows(field=f, limit=2)`,
|
||||
exp: []string{"0", "1"},
|
||||
},
|
||||
{
|
||||
q: `Rows(f, previous="15")`,
|
||||
exp: []string{"16", "17", "18"},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue