-
Notifications
You must be signed in to change notification settings - Fork 24
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
Bugfix: APathToXPathConverter always put assignment before literals #594
Conversation
…would get an assignment before the literal, even if the assignment would be in the provided query. Also add tests for APathToXPathConverter.java with fixed scenarios.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #594 +/- ##
============================================
+ Coverage 71.76% 71.79% +0.03%
- Complexity 6948 6953 +5
============================================
Files 663 663
Lines 22691 22691
Branches 3674 3675 +1
============================================
+ Hits 16284 16292 +8
+ Misses 4670 4666 -4
+ Partials 1737 1733 -4 ☔ View full report in Codecov by Sentry. |
public class APathToXPathConverterTest { | ||
|
||
@Test | ||
public void rootPath() throws Exception { |
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.
public void rootPath() throws Exception { | |
public void rootPath() { |
@@ -113,52 +107,50 @@ public static String convertWithAntlr(String query) { | |||
*/ | |||
private static void writeTree(StringBuilder output, ParseTree tree, boolean inPredicate) { | |||
|
|||
|
|||
for(int i = 0; i < tree.getChildCount(); i++) { | |||
for (int i = 0; i < tree.getChildCount(); i++) { |
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.
This is inconsistent with the rest of the file currently, so reformat on the full file please :)
When converting a query path to a
XPath
, inAPathToXPathConverter.writeTree
the output would always get an assignment before a literal, independent if it would already be provided in the query itself.For example, when query:
items[id5]
, this would becomeitems[\@archetype_node_id = 'id5']
butitems[\@archetype_node_id='id5'] would become
items[@archetype_node_id = @archetype_node_id = 'id5']Fixed this by setting the
inPredicateboolean to false whenever encountering a
EqualExprContext` with more than 3 children (being an indication it has format with predefined assignment).