-
Notifications
You must be signed in to change notification settings - Fork 66
helper:assert-throws-error, xdmp:apply, varargs #503
Comments
I think you found the best solution for the moment, though I wonder if you need to distinguish between all numbers of args like in the 2011 post. That link also proposes to use map:map to pass through arguments, which solves passing through sequences as argument. Or perhaps json:array would be practical here. Definitely a bug.. |
Fixed #503: leveraged json:array to fix helper function
Looks like a previous PR missed a return after adding a let. Maybe that was just a rebasing problem or something, but it led to invalid syntax.
Fixed in dev.. |
This is not actually working from what I can tell. There are 2 problems that i see, one is that the way the cascade of function calls are built, it will not work with <6 parameters. What ends up happening is that all sample functions get called with 6 parameters, with the balance being the empty sequence. Once that was corrected, I noticed a different problem/limitation in See attached patch for a fix: I can make a pull-request if that is helpful, but didn't seem necessary for such a small diff. |
Hmm, not sure my patch is correct... I think sending an empty sequence to an XQuery function as an argument in this case the function will receive an empty JSON array instead... I need to double check that when I get a chance. UPDATE: Nevermind, I think it is OK after all. The json:array-values() does seem to work correctly to convert an empty json array into an empty sequence. The only trouble would come in if you tried to test a function with arrity > 6 and also sent some arguments as empty-sequence and it hit the fallback statement. |
:) Feel free to reopen again, or file a new ticket if you think those edge cases can be a real issue.. |
I have a function I want to test. It takes 6 parameters. If I call
helper:assert-throws-error
, I get a “Too few args” error message. The error is actually occurring at line 295.I think this might be a bug because xdmp:apply seems to require the $params be itemized. Instead of this
You seem to have to do this:
(Side note: Some googling turned up this 2011 post discussing the ‘varargs’ aspect of
xdmp:apply
.)I’ve actually implemented a fix locally and it seems to work. Of course, it has all ugliness mentioned in the above post. Happy to submit a pull request if, in fact, this is an issue.
If it isn’t an issue, please advise how one uses
helper:assert-throws-error
with multiple vars.The text was updated successfully, but these errors were encountered: