spring-projects / spring-projects/spring-data-couchbase
partial match on @Id expands incorrectly [DATACOUCH-407]
@davidkelly is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 284
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
Jochem van Dieten opened DATACOUCH-407 and commented
When doing a partial match on the Id of a document using N1QL generated queries the keywords Like, StartingWith etc. expand incorrectly. Instead of expanding to meta().id LIKE 'value' they expand to *id :LIKE "value"*.
The document class:
public class Test {
@Id
private String id;
@Field
private String value;
}
The repository:
public interface TestRepository extends CrudRepository<Test, String> {
ArrayList<Test> findByIdLike(String id);
ArrayList<Test> findByIdStartingWith(String id);
ArrayList<Test> findByValueLike(String value);
ArrayList<Test> findByValueStartingWith(String value);
}
The integration test:
public void testPrefixQueries() {
assertEquals(0, testRepository.findByIdLike("test%").size());
assertEquals(0, testRepository.findByIdStartingWith("test").size());
assertEquals(34, testRepository.findByValueLike("x17%").size());
assertEquals(34, testRepository.findByValueStartingWith("x17").size());
}
With *logging.level.org.springframework.data.couchbase.*=*``*DEBUG* in application.properties this gives the following debug output:
2018-09-23 12:51:37.585 DEBUG 6418 --- [ main] o.s.d.c.r.query.AbstractN1qlBasedQuery : Executing N1QL query: {"statement":"SELECT META(`springboot`).id AS _ID, META(`springboot`).cas AS _CAS, `springboot`.* FROM `springboot` WHERE (`id` LIKE \"test%\") AND `_class` = \"com.or.routing.model.document.Test\"","scan_consistency":"statement_plus"}
2018-09-23 12:51:38.045 DEBUG 6418 --- [ main] o.s.d.c.r.query.AbstractN1qlBasedQuery : Executing N1QL query: {"statement":"SELECT META(`springboot`).id AS _ID, META(`springboot`).cas AS _CAS, `springboot`.* FROM `springboot` WHERE (`id` LIKE \"test%\") AND `_class` = \"com.or.routing.model.document.Test\"","scan_consistency":"statement_plus"}
2018-09-23 12:51:38.499 DEBUG 6418 --- [ main] o.s.d.c.r.query.AbstractN1qlBasedQuery : Executing N1QL query: {"statement":"SELECT META(`springboot`).id AS _ID, META(`springboot`).cas AS _CAS, `springboot`.* FROM `springboot` WHERE (`value` LIKE \"x17%\") AND `_class` = \"com.or.routing.model.document.Test\"","scan_consistency":"statement_plus"}
2018-09-23 12:51:38.935 DEBUG 6418 --- [ main] o.s.d.c.r.query.AbstractN1qlBasedQuery : Executing N1QL query: {"statement":"SELECT META(`springboot`).id AS _ID, META(`springboot`).cas AS _CAS, `springboot`.* FROM `springboot` WHERE (`value` LIKE \"x17%\") AND `_class` = \"com.or.routing.model.document.Test\"","scan_consistency":"statement_plus"}
Affects: 3.0.10 (Kay SR10)
Referenced from: pull request https://github.com/spring-projects/spring-data-couchbase/pull/175
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.