Skip to content

Have the option of NOT having the type predicate (i.e. _class = '<class-name>' in queries. #1654

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

Closed
mikereiche opened this issue Jan 26, 2023 · 4 comments · Fixed by #1777
Closed
Assignees

Comments

@mikereiche
Copy link
Collaborator

Have the option of NOT having the type predicate (i.e. _class = '' in queries.

The most logical solution would be to simply use 1=1 in place of _class=. This could be achieved by specifying the typeKey=1 and typeAlias=1 - except that back-ticks are automatically used to escape the typeKey.

@mikereiche mikereiche self-assigned this Jan 26, 2023
@mikereiche
Copy link
Collaborator Author

mikereiche commented Jan 26, 2023

@@ -229,7 +229,8 @@ public class StringBasedN1qlQueryParser {
-               String typeSelection = "`" + typeField + "` = \"" + typeValue + "\"";
+               String typeSelection =
+                       typeField == null ? null : ( typeField.equals("1") ? "1=1" : ("`" + typeField + "` = \"" + typeValue + "\""));

@@ -77,12 +77,12 @@ public class N1qlJoinResolver {
-               String onLks = "lks." + n1qlL.filter;
+               String onLks = n1qlL.filter != null  && !n1qlL.filter.equals("1=1") ? "lks." + n1qlL.filter : null;
...
-               String onRks = "rks." + n1qlR.filter;
+               String onRks = n1qlR.filter != null && !n1qlR.filter.equals("1=1") ?  "rks." + n1qlR.filter :null;

@@ -107,7 +107,9 @@ public class N1qlJoinResolver {
-               String on = "ON " + parameters.getJoinDefinition().on().concat(" AND " + onLks).concat(" AND " + onRks);
+               String on = "ON " + parameters.getJoinDefinition().on();
+               on = onLks != null ? " AND " + onLks : on;
+               on = onRks != null ? " AND " + onRks : on;

@mikereiche
Copy link
Collaborator Author

See #493

@mikereiche
Copy link
Collaborator Author

Folks - please read the end of the sentence : "This could be achieved by specifying the typeKey=1 and typeAlias=1 - except that back-ticks are automatically used to escape the typeKey".

@mikereiche
Copy link
Collaborator Author

Fixed by #1777.
"If the configuration getType() or the https://github.com/typealias is an empty string, then do not add the typeKey:typeAlias property when storing documents, and do not add the typeKey=typeAlias property on queries - including removeByQuery."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant