Skip to content

partial match on @Id expands incorrectly [DATACOUCH-407] #719

Open
@spring-projects-issues

Description

@spring-projects-issues

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 #175

Metadata

Metadata

Assignees

Labels

in: mappingMapping and conversion infrastructurein: repositoryRepositories abstractiontype: bugA general bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions