mirror of
https://github.com/pikami/cosmium.git
synced 2026-10-10 12:11:01 +01:00
Fix ARRAY_CONTAINS panic when optional partial-match argument is omitted (#14)
* Fix ARRAY_CONTAINS panic when partial match arg is omitted The NoSQL parser always emits a third (nil) argument for the optional partial-match flag of ARRAY_CONTAINS. The executor checked only len(arguments) > 2 before type-asserting arguments[2] to parsers.SelectItem, which panicked on the nil value whenever the query omitted the partial-match argument (e.g. ARRAY_CONTAINS(c.arr, 2)). Guard the type assertion with a nil check and add an API test covering ARRAY_CONTAINS with and without the optional partial-match argument. Co-authored-by: Pijus Kamandulis <[email protected]> * Remove comments from ARRAY_CONTAINS API test Co-authored-by: Pijus Kamandulis <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
This commit is contained in:
co-authored by
Cursor Agent
parent
d76cc88175
commit
c3726a6633
@@ -25,7 +25,7 @@ func (r rowContext) array_Contains(arguments []interface{}) bool {
|
||||
exprToSearch := r.resolveSelectItem(arguments[1].(parsers.SelectItem))
|
||||
|
||||
partialSearch := false
|
||||
if len(arguments) > 2 {
|
||||
if len(arguments) > 2 && arguments[2] != nil {
|
||||
boolExpr := r.resolveSelectItem(arguments[2].(parsers.SelectItem))
|
||||
if boolValue, ok := boolExpr.(bool); ok {
|
||||
partialSearch = boolValue
|
||||
|
||||
Reference in New Issue
Block a user