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

several atomic comparisons raise wrong error code #1638

Closed
telic opened this Issue Nov 28, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@telic
Contributor

telic commented Nov 28, 2017

What is the problem

Depending on the order of an atomic comparison, eXist inconsistently raises either a generic error (exerr:ERROR), err:FORG0001, or the expected err:XPTY0004 error.

This appears to be due to inconsistent practice in the implementation of the compareTo(Collator, Comparison, AtomicValue) method in each of the org.exist.xquery.value classes. Specifically, AbstractDateTimeValue, BinaryValue, and NumericValue all raise generic errors. AnyURIValue raises err:FORG0001 if compared to anything that cannot be cast to an xs:anyURI.

What did you expect

Comparisons of incompatible types should always raise err:XPTY0004, regardless of the comparison order and types involved. Eg. 5 eq 'five', 'five' eq 5, and xs:anyURI('5') eq 5 should all raise err:XPTY0004.

Context information

  • eXist-db 3.6.0 (build 201711271542) / ceaab01
  • Java 1.8.0_152-b16
  • MacOS 10.13.1
  • 64 bit

Related: #1630

@dizzzz

This comment has been minimized.

Show comment
Hide comment
@dizzzz

dizzzz Dec 3, 2017

Member

as I see it, err:XPTY0004 can be thrown into context of sequence matching whilst err:FORG0001 is thrown in the context of type casting. The stacktrace of your examples indicate this direction:

Caused by: org.exist.xquery.XPathException: err:FORG0001 cannot convert 'xs:integer (5)' into xs:anyURI
	at org.exist.xquery.value.IntegerValue.convertTo(IntegerValue.java:317)
	at org.exist.xquery.value.AnyURIValue.compareTo(AnyURIValue.java:297)

for sure 5 eq 'five' should yield into a better error....

Member

dizzzz commented Dec 3, 2017

as I see it, err:XPTY0004 can be thrown into context of sequence matching whilst err:FORG0001 is thrown in the context of type casting. The stacktrace of your examples indicate this direction:

Caused by: org.exist.xquery.XPathException: err:FORG0001 cannot convert 'xs:integer (5)' into xs:anyURI
	at org.exist.xquery.value.IntegerValue.convertTo(IntegerValue.java:317)
	at org.exist.xquery.value.AnyURIValue.compareTo(AnyURIValue.java:297)

for sure 5 eq 'five' should yield into a better error....

@dizzzz dizzzz assigned dizzzz and unassigned adamretter Dec 3, 2017

RemiKoutcherawy added a commit to RemiKoutcherawy/exist that referenced this issue Dec 24, 2017

RemiKoutcherawy added a commit to RemiKoutcherawy/exist that referenced this issue Jan 1, 2018

RemiKoutcherawy added a commit to RemiKoutcherawy/exist that referenced this issue Jan 1, 2018

adamretter added a commit that referenced this issue Jan 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment