Skip to content

Commit ef1dab5

Browse files
committed
Add tests on in for other literals
1 parent db96462 commit ef1dab5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ func engineType(p Predicate) EngineType {
636636
// btrees, texts require ARTs, and so on.
637637
switch v := p.Literal.(type) {
638638
case int, int64, float64:
639-
if p.Operator == operators.NotEquals {
639+
if p.Operator == operators.NotEquals || p.Operator == operators.In {
640640
return EngineTypeNone
641641
}
642642
// return EngineTypeNone

expr_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,34 @@ func TestInMacro(t *testing.T) {
12711271
require.Equal(t, ex, found[0])
12721272
})
12731273
})
1274+
1275+
t.Run("number as literal", func(t *testing.T) {
1276+
ctx := t.Context()
1277+
1278+
e := newTestEvaluator()
1279+
1280+
ex := tex(`3.50 in event.data.amounts`)
1281+
_, err := e.Add(ctx, ex)
1282+
require.NoError(t, err)
1283+
1284+
// As this is a string equality match, this should be a fast expression.
1285+
require.EqualValues(t, 0, e.FastLen())
1286+
require.EqualValues(t, 1, e.SlowLen())
1287+
})
1288+
1289+
t.Run("array as literal", func(t *testing.T) {
1290+
ctx := t.Context()
1291+
1292+
e := newTestEvaluator()
1293+
1294+
ex := tex(`event.data.id in ["abc", "def"]`)
1295+
_, err := e.Add(ctx, ex)
1296+
require.NoError(t, err)
1297+
1298+
// As this is a string equality match, this should be a fast expression.
1299+
require.EqualValues(t, 0, e.FastLen())
1300+
require.EqualValues(t, 1, e.SlowLen())
1301+
})
12741302
}
12751303

12761304
// newTestEvaluator

0 commit comments

Comments
 (0)