Details
Description
In versions prior to 4.6.2 it is not possible to use arbitrary variable names with array indexes (see https://issues.couchbase.com/browse/MB-22646).
As I'm using 4.5.1 CE I did use the exact same variable name as in the index definition. As I had to 2 where clauses using the same index, I've used the same variable name twice (even though in different parenthesis).
select meta(`holder`).`id`
|
from `mybucket` as `holder`
|
where ClassName = 'ObjectName' AND |
(ANY `refKey` IN `holder`.`refKeys` SATISFIES [`refKey`.`key`, `refKey`.`value`] = ['KEY1', 'VALUE1'] END) AND |
(ANY `refKey` IN `holder`.`refKeys` SATISFIES [`refKey`.`key`, `refKey`.`value`] = ['KEY2', 'VALUE2'] END) |
when doing the results are random and different every time I do execute this query (sometimes all results are returned, sometimes just a few and in most cases none) which made me think it might be a concurrency issue.
When using different variable names in the two collection operators everything is working as expected:
select meta(`holder`).`id`
|
from `mybucket` as `holder`
|
where ClassName = 'ObjectName' AND |
(ANY `refKey` IN `holder`.`refKeys` SATISFIES [`refKey`.`key`, `refKey`.`value`] = ['KEY1', 'VALUE1'] END) AND |
(ANY `refKey1` IN `holder`.`refKeys` SATISFIES [`refKey1`.`key`, `refKey1`.`value`] = ['KEY2', 'VALUE2'] END) |
In versions prior to 4.6.2 this obviously results in the index not being used for the second collection operator, but at least there is a workaround, so it's not super urgent. But it's something which can easily happen and cause unexpected results.
Attachments
Issue Links
- is duplicated by
-
MB-21720 AND of ANY / EVERY does not work with array indexes
-
- Closed
-