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] tails of subsequences off by one #4850

Merged
merged 1 commit into from
Apr 19, 2023

Conversation

line-o
Copy link
Member

@line-o line-o commented Apr 4, 2023

Description:

Tails of subsequences are no longer off by one.

Reference:

fixes #4830

Type of tests:

XQSuite tests

@line-o
Copy link
Member Author

line-o commented Apr 4, 2023

Wow, 17 additional XQTS test pass!
https://github.com/eXist-db/exist/actions/runs/4606829733/jobs/8140603210?pr=4850#step:15:29

@line-o
Copy link
Member Author

line-o commented Apr 4, 2023

Quite a reward for removing a few characters from such a large codebase.

Copy link
Contributor

@duncdrum duncdrum left a comment

Choose a reason for hiding this comment

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

Ouch quite a find needs a rebase

@line-o
Copy link
Member Author

line-o commented Apr 6, 2023

rebased onto current develop

@duncdrum
Copy link
Contributor

duncdrum commented Apr 6, 2023

@line-o thx looks good to me

@duncdrum duncdrum self-requested a review April 6, 2023 18:49
@@ -204,7 +204,7 @@ public Sequence tail() {
return Sequence.EMPTY_SEQUENCE;
}

return new SubSequence(fromInclusive + 1, toExclusive -1, sequence);
return new SubSequence(fromInclusive + 1, toExclusive, sequence);
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

%test:args(1,5)
%test:assertEquals(2,3,4,5)
function ss:tail($start, $length) {
subsequence((1 to 5), $start, $length) => tail()
Copy link
Member

@adamretter adamretter Apr 7, 2023

Choose a reason for hiding this comment

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

Can you remove the unnecessary Arrow Operator please? For the reasons:

  1. As previously discussed the ability to debug such constructs within XQuery from Java is not at all easy.
  2. It is not at all required, the test only needs the two functions: tail(subsequence((1 to 5), $start, $length)). Ideally tests should only have the required components.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you really think this warrants to reject this PR?

Copy link
Member Author

@line-o line-o Apr 14, 2023

Choose a reason for hiding this comment

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

The existing XQSuite test case above the newly added one has an arrow operator as well.
I also do used this new test case to debug and fix the issue. It is certainly possible.

Copy link
Member

@adamretter adamretter Apr 14, 2023

Choose a reason for hiding this comment

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

his warrants to reject this PR?

I am not rejecting the PR, I am asking for a very small change that has a positive impact. Surely the purpose of the peer-review process is exactly for this purpose.

The existing XQSuite test case above the newly added one has an arrow operator as well.

I don't see what bearing that has on your changes. If the existing code was perfect, then we would never need to make changes to eXist-db! When we are making changes, these days, we follow the peer-review process, which hopefully leads to agreed improvements to the code base.

@line-o line-o requested a review from adamretter April 14, 2023 09:42
Copy link
Member

@adamretter adamretter left a comment

Choose a reason for hiding this comment

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

The test-case can be simplified to its actual purpose by removing the (unnecessary) arrow operator.

@line-o
Copy link
Member Author

line-o commented Apr 19, 2023

For the sake of getting this PR, and it's backport #4851, merged I will change the test.
I will open a separate issue to get to a consensus how to write XQSuite tests and have that documented somewhere.

@sonarcloud
Copy link

sonarcloud bot commented Apr 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@adamretter adamretter left a comment

Choose a reason for hiding this comment

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

Thanks for the improvements. Now LGTM :-)

@adamretter adamretter merged commit 7ed15a3 into eXist-db:develop Apr 19, 2023
9 of 12 checks passed
@line-o line-o deleted the fix/4830 branch July 21, 2023 10:13
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 this pull request may close these issues.

[BUG] XQuery bug of node selection of tail() after subsequence()
4 participants