committed by
mikereiche
parent
728aabdfa0
commit
559ba38ac8
@@ -1130,7 +1130,7 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter implem
|
||||
}
|
||||
}
|
||||
|
||||
String maybeMangle(PersistentProperty<?> property) {
|
||||
public String maybeMangle(PersistentProperty<?> property) {
|
||||
Assert.notNull(property, "property");
|
||||
if (!conversions.hasValueConverter(property)) {
|
||||
return ((CouchbasePersistentProperty) property).getFieldName();
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.util.regex.Pattern;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.couchbase.core.convert.CouchbaseConverter;
|
||||
import org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter;
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbaseDocument;
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbaseList;
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
|
||||
@@ -332,7 +333,13 @@ public class StringBasedN1qlQueryParser {
|
||||
if (fieldList == null || fieldList.contains(prop.getFieldName())) {
|
||||
PersistentPropertyPath<CouchbasePersistentProperty> path = couchbaseConverter.getMappingContext()
|
||||
.getPersistentPropertyPath(prop.getName(), persistentEntity.getTypeInformation().getType());
|
||||
projectField = N1qlQueryCreator.addMetaIfRequired(bucketName, path, prop, persistentEntity).toString();
|
||||
String unmangled = prop.getFieldName();
|
||||
String maybeMangled =((MappingCouchbaseConverter)couchbaseConverter).maybeMangle(prop);
|
||||
if(maybeMangled.equals(unmangled)) {
|
||||
projectField = N1qlQueryCreator.addMetaIfRequired(bucketName, path, prop, persistentEntity).toString();
|
||||
} else {
|
||||
projectField = i(maybeMangled).toString();
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
|
||||
@@ -154,10 +154,14 @@ public class CouchbaseRepositoryFieldLevelEncryptionIntegrationTests extends Clu
|
||||
assertFalse(userEncryptedRepository.existsById(user.getId()));
|
||||
userEncryptedRepository.save(user);
|
||||
// read the user with Spring
|
||||
|
||||
Optional<UserEncrypted> writeSpringReadSpring = userEncryptedRepository.findById(user.getId());
|
||||
assertTrue(writeSpringReadSpring.isPresent());
|
||||
writeSpringReadSpring.ifPresent(u -> assertEquals(user, u));
|
||||
|
||||
List<UserEncrypted> writeSpringReadSpring2 = userEncryptedRepository.findAll();
|
||||
assertEquals(user, writeSpringReadSpring2.stream().filter(u -> u.getId().equals(user.getId())).findFirst().get());
|
||||
|
||||
if (cleanAfter) {
|
||||
try {
|
||||
couchbaseTemplate.removeById(UserEncrypted.class).one(user.getId());
|
||||
|
||||
Reference in New Issue
Block a user