Closed
Description
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());
}
}