I have 20 documents with meta ids like:
and 20 documents with meta ids like:
The following statement incorrectly returns 40 documents:
SELECT COUNT(*) FROM bucket WHERE meta().id LIKE 'document_%'
What’s more, if I treat underscore as an escape char, and try doubling, it also fails (returning 40 documents instead of 20):
SELECT COUNT(*) FROM bucket WHERE meta().id LIKE 'document__%'
Insanely, the only way to get the query to correctly return 20 documents is to place EIGHT underscores:
SELECT COUNT(*) FROM bucket WHERE meta().id LIKE 'document________%'
This appears to be a significant bug.
July 22, 2021, 2:19pm
This is upcoming 6.6.3, Post exact version you are using. cc
insert into default values ("k|01",1), values ("k|02",1), values ("k_01",1), values ("k_02",1);
-- _ is escape character in like
select count(1) FROM default WHERE meta().id LIKE 'k_%' ;
-- treat under score as non escape character
select count(1) FROM default WHERE meta().id LIKE 'k\\_%' ;
Match string with a wildcard expression. Use % for zero or more wildcards and _ to match any character at this place in a string.
The wildcard characters can be escaped by preceding them with a backslash (). Backslash itself can also be escaped by preceding it with another backslash.
I’m using 7.0 beta.
Thanks for the info.
I’m confused by the concept of the 2 placeholders, which appear to be identical. How are they in any way different?
For example, how is
LIKE 'x%yz' any different than
July 22, 2021, 3:16pm
It should work in 7.0.0 beta. 7.0.0 has more fixes in this area
_ matches one character only, % matches more than one
"x_y" true of " xay", false of "xaby"
"x%y" will true for both