Skip to content

[BUG] behaviour of map:merge#1 is not standards compliant #3750

Description

@line-o

Describe the bug

@adamretter found out that the handling of duplicate keys when merging maps with map:merge is not according to the specification.
Exists uses use-last whereas the XQuery 3.1 specification states use-first must be used.

Expected behavior

Existdb's implementation of map:merge#1 to adhere to the specification.

To Reproduce

xquery version "3.1";

module namespace t="http://exist-db.org/xquery/test";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare
    %test:assertTrue
function t:test() {
    let $m1 := map{'a':1}
    let $m2 := map{'a':2}
    let $merged := map:merge(($m1, $m2))
    return $merged?a eq $m1?a
};

Context (please always complete the following information):

eXist-db version: 5.3.0-SNAPSHOT
likely all implementations of map:merge are affected

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugissue confirmed as bugxqueryissue is related to xquery implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions