DATACOUCH-583 - Nested properties in queries not working. (#270)
The complete property path was being quoted instead of the individual components. ie. `address.street` instead of `address`.`street` Also fixed another issue - changed the maybeQuote() method for property names to correctly look for back-tics instead of double quotes and changed the name accordingly. Co-authored-by: mikereiche <michael.reiche@couchbase.com>
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import com.couchbase.client.java.query.QueryScanConsistency;
|
||||
import org.springframework.data.couchbase.repository.Query;
|
||||
import org.springframework.data.couchbase.repository.ScanConsistency;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
@@ -105,4 +107,6 @@ public interface PersonRepository extends CrudRepository<Person, String> {
|
||||
|
||||
void deleteAll();
|
||||
|
||||
}
|
||||
@ScanConsistency(query=QueryScanConsistency.REQUEST_PLUS)
|
||||
List<Person> findByAddressStreet(String street);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.couchbase.CouchbaseClientFactory;
|
||||
import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration;
|
||||
import org.springframework.data.couchbase.domain.Address;
|
||||
import org.springframework.data.couchbase.domain.Airport;
|
||||
import org.springframework.data.couchbase.domain.AirportRepository;
|
||||
import org.springframework.data.couchbase.domain.Person;
|
||||
import org.springframework.data.couchbase.domain.PersonRepository;
|
||||
import org.springframework.data.couchbase.repository.config.EnableCouchbaseRepositories;
|
||||
import org.springframework.data.couchbase.util.Capabilities;
|
||||
import org.springframework.data.couchbase.util.ClusterAwareIntegrationTests;
|
||||
@@ -82,6 +85,24 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired PersonRepository personRepository;
|
||||
|
||||
@Test
|
||||
void nestedFind() {
|
||||
Person person = null;
|
||||
try {
|
||||
person = new Person(1, "first", "last");
|
||||
Address address = new Address();
|
||||
address.setStreet("Maple");
|
||||
person.setAddress(address);
|
||||
personRepository.save(person);
|
||||
List<Person> persons = personRepository.findByAddressStreet("Maple");
|
||||
assertEquals(1, persons.size());
|
||||
} finally {
|
||||
personRepository.deleteById(person.getId().toString());
|
||||
}
|
||||
}
|
||||
|
||||
// "1\" or name=name or name=\"1")
|
||||
@Test
|
||||
void findByInjection() {
|
||||
|
||||
Reference in New Issue
Block a user