Skip to content

fields renamed with Field(fieldName) annotation not deserialized in n1ql queries #1184

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
mikereiche opened this issue Aug 13, 2021 · 0 comments · Fixed by #1185
Closed

fields renamed with Field(fieldName) annotation not deserialized in n1ql queries #1184

mikereiche opened this issue Aug 13, 2021 · 0 comments · Fixed by #1185
Labels
type: bug A general bug

Comments

@mikereiche
Copy link
Collaborator

fields renamed with Field(fieldName) annotation not deserialized in n1ql queries. The issue is that StringBasedN1qlQueryParser does not use getFieldName() when projecting fields.

A customer also reports that this occurs with the KV api (findById), but I am not able to reproduce that.
If the customer has defined a new findById() method (i.e. not overriden the one in SimpleCouchbaseRepository), then the n1ql query will be used. For example, in the test below, if PersonRepository defined a findById(UUID), that would use the n1ql api, while findById(String) would use the KV api.

@Test
void annotatedFieldFind() {
	Person person = null;
	try {
		person = new Person(1, "first", "last");
		person.setMiddlename("Nick"); // middlename is stored as nickname
		personRepository.save(person);
		Person person2 = personRepository.findById(person.getId().toString()).get();
		assertEquals(person.getMiddlename(), person2.getMiddlename());
		List<Person> persons3 = personRepository.findByMiddlename("Nick");
		assertEquals(1, persons3.size());
		assertEquals(person.getMiddlename(), persons3.get(0).getMiddlename());
	} finally {
		personRepository.deleteById(person.getId().toString());
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant