-
Notifications
You must be signed in to change notification settings - Fork 192
QueryCriteria.where() adds backticks to ALL keys, breaks keys that use META() #1066
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
Comments
the "key" of a criteria is a String (fieldname) and gets back-ticks around it. Also where() takes a String argument (which in turn becomes the "key" of the criteria so there are couple issues. Writing the predicate the other way around will give the correct form for the RHS, but the LHS will again be incorrect as it is encapsulated in back-ticks. |
@mikereiche I'm not sure if that helps? What is needed here is probably a way to take a higher level object other than a String that can be used to represent complex keys that are not subject to the default quotation.. And I imagine that you could probably refactor much of the Something vaguely like this, for inspiration. QueryCriteria.where(Condition.field("deleted")).eq(false);
QueryCriteria.where(Condition.meta("bucketname", "cas")).eq(version); |
Right. That's why I pointed out the limitation "where() takes a String argument". Allowing the argument to be a N1qlExpression would work (there's no reason that it should be restricted to a string property-name). That's why I pointed out that the argument for eq() is allowed to be a N1qlExpression and does not have the same problem. An even simpler solution would be to not assume the string arg to where() is a property-name and should be escaped. |
OK, you didn't mention So what are the next steps? |
Adding support for a where(N1qlExpression) method. This would require changing the "key" of QueryCriteria from a String to a N1QLExpression. Unrelated to the where(N1lqExpression) issue - the CAS in n1ql should always be treated as a string, not a number. |
This is a merge of mmonti's changeset into master. The changeset was made on top of 4.1.x instead of master so it has a little catching up to do. Merge branch 'gh-1066-n1qlexpression-as-querycriteria-key' of github.com:mmonti/spring-data-couchbase into datacouch_1066_1072_mmonti_n1ql_query_creator_expression Original pull request #1076
For example:
produces a query like so:
The text was updated successfully, but these errors were encountered: