Skip to content

Problem with query creation using the IN operator #1308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cbusquet opened this issue Jan 24, 2022 · 3 comments · Fixed by #1309
Closed

Problem with query creation using the IN operator #1308

cbusquet opened this issue Jan 24, 2022 · 3 comments · Fixed by #1309
Labels
type: regression A regression from a previous release

Comments

@cbusquet
Copy link

I am using spring data couchbase 4.3.1

There seems to be a problem with query creation in the way the IN operator values are mapped.

Here's my repository declaration :

@Repository
public interface OperationRepository extends CrudRepository<Operation, OperationId> {
    
    List<Operation> findBySizeInAndColorIn(Collection<String> size, Collection<String> color, Pageable pageable);
}

Here's the kind of error I get when one of the collections has a size greater than 1 :

com.couchbase.client.core.error.ParsingFailureException: Parsing of the input failed {"completed":true,"coreId":"0x7377828300000001","errors":[{"code":3000,"message":"syntax error - at ,"}],"httpStatus":400,"idempotent":false,"lastDispatchedFrom":"127.0.0.1:61266","lastDispatchedTo":"localhost:8093","requestId":1488,"requestType":"QueryRequest","retried":0,"service":{"operationId":"a3011a48-ea7d-43d8-8f42-880a30c6a0b9","statement":"SELECT META(`mybucket`).id AS __id, META(`mybucket`).cas AS __cas, `name`, `size`, `color` FROM `mybucket` WHERE `_class` = \\\"com.mycompany.Product\\\" AND `size` in ( $1 ) and `color` in ( $2, $3 ) LIMIT 30","type":"query"},"timeoutMs":75000,"timings":{"dispatchMicros":5104,"totalDispatchMicros":5104,"totalMicros":10541}}
	at com.couchbase.client.core.io.netty.query.QueryChunkResponseParser.errorsToThrowable(QueryChunkResponseParser.java:140) ~[core-io-2.2.4.jar:na]
	at java.base/java.util.Optional.map(Optional.java:265) ~[na:na]
	at com.couchbase.client.core.io.netty.query.QueryChunkResponseParser.error(QueryChunkResponseParser.java:124) ~[core-io-2.2.4.jar:na]
...

The query in a more readable form :

SELECT META(`mybucket`).id AS __id, META(`mybucket`).cas AS __cas, `name`, `size`, `color` 
FROM `mybucket` 
WHERE `_class` = "com.mycompany.Produc" AND `size` in ( $1 ) and `color` in ( $2, $3 ) 
LIMIT 30

The IN operator seems to work fine with parentheses for just one value but it seems brackets are needed for a list of values.
The couchbase documentation doesn't even mentions parentheses, only brackets :

https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/collectionops.html#collection-op-in

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 24, 2022
@mikereiche
Copy link
Collaborator

What server version?

@mikereiche mikereiche added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 24, 2022
@cbusquet
Copy link
Author

Couchbase 6.5.1

I upgraded to 4.3.1 when going from spring boot 2.6.2 to 2.6.3

With 2.6.2 the repository used arrays instead of collections and it worked fine. With the new version, neither arrays nor collections seem to work.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 24, 2022
@mikereiche
Copy link
Collaborator

There's a change in 4.3 to make it work with a change in 7.1. https://issues.couchbase.com/browse/MB-26606
I'm looking at what can be done. Maybe handle the different server versions differently or just roll-back that change.

@mikereiche mikereiche added type: regression A regression from a previous release and removed status: feedback-provided Feedback has been provided labels Jan 24, 2022
mikereiche added a commit that referenced this issue Jan 24, 2022
mikereiche added a commit that referenced this issue Jan 25, 2022
mikereiche added a commit that referenced this issue Feb 4, 2022
mikereiche added a commit that referenced this issue Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants