fix(storage,sqlite): in operator sqlite translation

This commit is contained in:
2023-02-17 16:59:05 +01:00
parent 673586c2f7
commit 85f50eb9d5
7 changed files with 102 additions and 13 deletions

View File

@ -60,6 +60,49 @@ var documentStoreQueryTestCases = []documentStoreQueryTestCase{
}
},
},
{
Name: "IN Operator",
Before: func(ctx context.Context, store storage.DocumentStore) error {
docs := []storage.Document{
{
"counter": 1,
"tags": []string{"foo", "bar"},
},
{
"counter": 1,
"tags": []string{"nope"},
},
}
for _, doc := range docs {
if _, err := store.Upsert(ctx, "in_operator", doc); err != nil {
return errors.WithStack(err)
}
}
return nil
},
Collection: "in_operator",
Filter: filter.New(
filter.NewAndOperator(
filter.NewEqOperator(map[string]any{
"counter": 1,
}),
filter.NewInOperator(map[string]any{
"tags": "foo",
}),
),
),
After: func(t *testing.T, results []storage.Document, err error) {
if err != nil {
t.Fatalf("%+v", errors.WithStack(err))
}
if e, g := 1, len(results); e != g {
t.Errorf("len(results): expected '%v', got '%v'", e, g)
}
},
},
}
func testDocumentStoreQuery(t *testing.T, store storage.DocumentStore) {