Skip to content

Problem with query creation using the IN operator #1308

Closed
@cbusquet

Description

@cbusquet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: regressionA regression from a previous release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions