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

The results of 'where' clause in FLWOR are different in memory and database. #2817

Open
jesselet opened this issue Jun 15, 2019 · 3 comments
Labels
bug issue confirmed as bug xquery issue is related to xquery implementation
Milestone

Comments

@jesselet
Copy link

jesselet commented Jun 15, 2019

What is the problem

for $i in $data1//item, $j in $data2//item
where $i/name = $j/name
return $i/name

The results of 'where' clause in FLWOR are different in memory and database.

What did you expect

The results of 'where' clause in FLWOR are the same in memory and database.

Describe how to reproduce or add a test

xquery version "3.0";
let $col := "/db/apps/test"
let $data1 :=
<data>
    <item><name>1</name></item>
    <item><name>2</name></item>
</data>
let $data2 :=
<data>
    <item><name>2</name></item>
    <item><name>3</name></item>
</data>
let $test := function ($data1, $data2) {
    for $i in $data1//item, $j in $data2//item
    where $i/name = $j/name
    return $i/name
}
return (
    try {
        $test($data1, $data2)
    } catch * { "test1: " || $err:description },
    (:in eXist 2.2, 3.6.1, 4.6.1, 4.7.0: OK:)

    try {
        xmldb:create-collection("", $col),
        let $data1 := doc(xmldb:store($col, "data1.xml", $data1))
        let $data2 := doc(xmldb:store($col, "data2.xml", $data2))
        return $test($data1, $data2)
    } catch * { "test2: " || $err:description }
    (:in eXist 2.2: OK:)
    (:in eXist 3.6.1, 4.6.1, 4.7.0: EXCEPTION: variable '$j' is not set:)
)

Context information

  • OS: Windows 7
  • Java: jre1.8.0_202
  • eXist-db: 2.2, 3.6.1, 4.6.1, 4.7.0
@triage-new-issues triage-new-issues bot added the triage issue needs to be investigated label Jun 15, 2019
@duncdrum duncdrum added the bug issue confirmed as bug label Jun 24, 2019
@triage-new-issues triage-new-issues bot removed the triage issue needs to be investigated label Jun 24, 2019
@duncdrum
Copy link
Contributor

yup confirmed, and looks like a bug that has been there for a while, ouch.

tested on 5.0.0-RC8-SNAPSHOT via docker

@line-o
Copy link
Member

line-o commented Jul 22, 2019

I would also see this as a bug.
It can be worked around with:

    let $j := $data2//item
    return
    for $i in $data1//item
    where $i/name = $j/name
    return $i/name

@line-o
Copy link
Member

line-o commented Jul 22, 2019

The equivalent form described in the spec does also fail:

    for $i in $data1//item
    for $j in $data2//item
    where $i/name = $j/name
    return $i/name

@joewiz joewiz added this to the eXist-5.0.0-RC8 milestone Jul 22, 2019
@adamretter adamretter modified the milestones: eXist-5.1.0, eXist-5.2.0 Nov 19, 2019
@adamretter adamretter modified the milestones: eXist-5.2.0, eXist-5.3.0 Jan 23, 2020
@line-o line-o added the xquery issue is related to xquery implementation label Apr 8, 2020
@adamretter adamretter modified the milestones: eXist-5.3.1, eXist-5.3.2 Dec 16, 2021
@adamretter adamretter modified the milestones: eXist-5.3.2, eXist-6.0.2 Feb 14, 2022
@adamretter adamretter modified the milestones: eXist-6.0.2, eXist-6.1.1 Jan 15, 2023
@adamretter adamretter modified the milestones: eXist-6.1.1, eXist-7.0.1 Feb 4, 2023
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

5 participants