-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix boolean parameter casting #24
Conversation
66d051b
to
07465ff
Compare
library module - xqm main module - xq
While the CI passes on the tests of eXist Here's the patch that enables the tests to pass under 7.0.0-SNAPSHOT: 0001-eXist-7.0.0-SNAPSHOT-compatibility.patch I do not know how to adjust the tests to be able to detect which matrix environment they're running under and to pass if the error code is 400 under eXist <7 and 500 under eXist >=7. |
@joewiz i think you would need to adjust the test function to execute system:get-version make the comparison inside the function and use assertTrue as Xqs annotation. Something along these lines. |
eXist 6.2.0 and earlier issues an error 400 when the fn:error function is called. With 7.0.0-SNAPSHOT (eXist-db/exist#4649), eXist issues an error 500. The precise error code is outside the scope of this package - it’s an issue decided by the eXist API - so we can accept either here.
@duncdrum Thanks for the pointer! I did a little more research and settled on a solution that hopefully makes sense. I changed the error code check from
All tests now pass. |
This works too, |
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.
Very nice fix @joewiz. I would still like to learn why a server error is an expected status code where it was only expecting a bad request before. Is this due to changes in existdb?
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.
LGTM. I think this warrants a patch release.
Before this PR, a function that declared a parameter as
xs:boolean
with a templating default value for this parameter was not cast toxs:boolean
.In eXist 7.0.0-SNAPSHOT, this led to an error in the function-documentation app. Specifically, app:module() function declares that
$details
parameter bexs:boolean
, and the templating annotation supplies a default value for this parameter, but when the function passes this default value to the app:print-module function, an error is raised because the function's signature requires this parameter to be of typexs:boolean
. Loading the landing page of the function documentation app raises the error shown below.This PR fixes the
templates:cast
function to ensure that templating defaults are correctly cast to match their function's signature when the signature requires them to bexs:boolean
.The hint that this problem was present was https://github.com/eXist-db/function-documentation/pull/64/files#r1187748791.