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

[BUG] xs:dateTimeStamp should promote to xs:dateTime (base type) #5478

Open
pherk opened this issue Oct 7, 2024 · 5 comments
Open

[BUG] xs:dateTimeStamp should promote to xs:dateTime (base type) #5478

pherk opened this issue Oct 7, 2024 · 5 comments
Labels
bug issue confirmed as bug xquery issue is related to xquery implementation

Comments

@pherk
Copy link

pherk commented Oct 7, 2024

Describe the bug
I'm upgrading an app from existdb 4.11 to 6.2
Comparing database values with fn:current-dateTime() produces an error: XPTY0004.

Expected behavior
I'm not an expert in XSD1.1, but type promotion should be expectable in my eyes.
I don't have Saxon or BaseX.

To Reproduce
eval in eXide:

xquery version "3.1";

declare function local:less($a as xs:string, $b as xs:dateTime) as xs:boolean
{
  if ($a="")
  then true()
  else xs:dateTime($a) <= $b
};
local:less("2024-01-01T00:00:00Z", fn:current-dateTime())

or eval

local:less("2024-01-01T00:00:00Z", xs:dateTimeStamp("2024-02-01T00:00:00.000Z"))

Context (please always complete the following information)

  • Build: [eXist-6.2.0 master]
  • Java: [1.8.0_352]
  • OS: [Ubuntu 24.0.1]

Additional context

  • How is eXist-db installed? [e.g. JAR installer, DMG, … ]
  • Any custom changes in e.g. conf.xml?
@line-o
Copy link
Member

line-o commented Oct 7, 2024

Hi @pherk!
Thank you for opening this issue. While the coercion from xs:dateTimestamp to xs:dateTime is done for the function parameter, the comparison fails.

xs:dateTime("2024-01-01T00:00:00") <= current-dateTime()

@line-o line-o added xquery issue is related to xquery implementation bug issue confirmed as bug labels Oct 7, 2024
@line-o
Copy link
Member

line-o commented Oct 7, 2024

I also tested this agains latest develop-6.x.x and develop branches. The issue is there as well.

@line-o
Copy link
Member

line-o commented Oct 7, 2024

The error description is:

It is a type error if, during the static analysis phase, an expression is found to have a static type that is not appropriate for the context in which the expression occurs, or during the dynamic evaluation phase, the dynamic type of a value does not match a required type as specified by the matching rules in 2.5.4 SequenceType Matching. Type error: cannot compare xs:dateTime to xs:dateTimeStamp

@adamretter
Copy link
Contributor

I think I recall fixing this in 7.0.0-SNAPSHOT already

@line-o
Copy link
Member

line-o commented Oct 8, 2024

The fix must be in an unmerged PR as latest develop is affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue confirmed as bug xquery issue is related to xquery implementation
Projects
None yet
Development

No branches or pull requests

3 participants