Skip to content

Commit

Permalink
🐛 add missing string.contains(dict)
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Richter <[email protected]>
  • Loading branch information
arlimus committed Jan 30, 2025
1 parent 5f14eec commit ebec5d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mql/mql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,15 @@ func TestDictMethods(t *testing.T) {
ResultIndex: 3,
Expectation: true,
},
{
Code: "'<< hello world >>'.contains(muser.dict.string)",
ResultIndex: 1,
Expectation: true,
},
{
Code: "'<< hello + world >>'.contains(muser.dict.string)",
ResultIndex: 1,
Expectation: false,
},
})
}
11 changes: 11 additions & 0 deletions mqlc/builtin_simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ func compileStringContains(c *compiler, typ types.Type, ref uint64, id string, c
},
})
return types.Bool, nil
case types.Dict:
c.addChunk(&llx.Chunk{
Call: llx.Chunk_FUNCTION,
Id: "contains" + string(types.Dict),
Function: &llx.Function{
Type: string(types.Bool),
Binding: ref,
Args: []*llx.Primitive{val},
},
})
return types.Bool, nil
case types.Array(types.String):
c.addChunk(&llx.Chunk{
Call: llx.Chunk_FUNCTION,
Expand Down

0 comments on commit ebec5d1

Please sign in to comment.