-
Notifications
You must be signed in to change notification settings - Fork 191
DATACOUCH-407 - Use meta prefix for metadata properties in N1ql predi… #175
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,10 @@ | |
import static org.springframework.data.couchbase.core.support.TemplateUtils.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.data.couchbase.core.convert.CouchbaseConverter; | ||
|
@@ -60,18 +63,15 @@ | |
* @author Mark Paluch | ||
*/ | ||
public class N1qlUtils { | ||
//As per https://docs.couchbase.com/server/5.5/n1ql/n1ql-language-reference/indexing-meta-info.html | ||
final static Set<String> META_PROPERTIES = new HashSet<>(Arrays.asList("id", "expiration", "cas")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be private? |
||
|
||
/** | ||
* A converter that can be used to extract the {@link CouchbasePersistentProperty#getFieldName() fieldName}, | ||
* eg. when one wants a path from {@link PersistentPropertyPath#toDotPath(Converter)} made of escaped field names. | ||
*/ | ||
public static final Converter<? super CouchbasePersistentProperty,String> FIELD_NAME_ESCAPED = | ||
new Converter<CouchbasePersistentProperty, String>() { | ||
@Override | ||
public String convert(CouchbasePersistentProperty source) { | ||
return "`" + source.getFieldName() + "`"; | ||
} | ||
}; | ||
(source) -> META_PROPERTIES.contains(source.getFieldName()) ? "META()." + source.getFieldName() : "`" + source.getFieldName() + "`"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if the document has a normal property called "id", "cas", or "expiration" -- can the user still reference it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes good point, will change the check to use the annotations instead and add the prefix. |
||
|
||
/** | ||
* Escape the given bucketName and produce an {@link Expression}. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style NIT: would be good to use braces, even for single-statement blocks.