Skip to content
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

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

EBrader
Copy link
Collaborator

@EBrader EBrader commented Apr 19, 2024

When converting a query path to a XPath, in APathToXPathConverter.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 become items[\@archetype_node_id = 'id5'] but
items[\@archetype_node_id='id5'] would become items[@archetype_node_id = @archetype_node_id = 'id5']Fixed this by setting theinPredicateboolean to false whenever encountering aEqualExprContext` with more than 3 children (being an indication it has format with predefined assignment).

…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.
@EBrader EBrader self-assigned this Apr 19, 2024
@EBrader EBrader requested a review from MattijsK April 19, 2024 13:16
Copy link

codecov bot commented Apr 19, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 71.79%. Comparing base (0d7494c) to head (cc810ed).

❗ Current head cc810ed differs from pull request most recent head 47ff7fb. Consider uploading reports for the commit 47ff7fb to get more accurate results

Files Patch % Lines
.../com/nedap/archie/query/APathToXPathConverter.java 84.61% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

public class APathToXPathConverterTest {

@Test
public void rootPath() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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++) {
Copy link
Collaborator

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 :)

@EBrader EBrader enabled auto-merge (squash) April 22, 2024 08:52
@EBrader EBrader merged commit 21d81dc into master Apr 22, 2024
1 of 2 checks passed
@EBrader EBrader deleted the pathbug branch April 22, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants