Semantics of cast/comparison/arithmetics involving null
Bug #1041445 reported by
Chris Hillery
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zorba |
Fix Released
|
High
|
Ghislain Fourny |
Bug Description
This is, I think, a bug / omission from the JSONiq spec.
There is no easy way to compare an item to see if it is null. You can use "instance of jdm:null", but you have to declare the jdm namespace - probably it should be pre-declared. However, IMHO at least, it would make much more sense to be able to do
where $o ne jn:null()
Unfortunately this throws an error if $o is not atomic.
Comparison and arithmetic on null is not defined by the spec. IMHO, the correct answer for comparison is that any type should be comparable to null, and anything except null should return false.
Dana's opinion is that when performing arithmetic on null, any operation should return null. ie, null + 1 = null, etc.
Related branches
lp:~zorba-coders/zorba/bug-1041445
- Matthias Brantner: Approve
- Till Westmann: Approve
-
Diff: 981 lines (+338/-120)42 files modifiedChangeLog (+1/-0)
include/zorba/store_consts.h (+1/-1)
modules/org/jsoniq/www/functions.xq (+20/-3)
src/api/serialization/serializer.cpp (+1/-1)
src/context/static_context.cpp (+2/-2)
src/context/static_context.h (+1/-1)
src/functions/func_jsoniq_functions_impl.cpp (+1/-1)
src/functions/pregenerated/func_jsoniq_functions.cpp (+29/-1)
src/functions/pregenerated/func_jsoniq_functions.h (+16/-0)
src/functions/pregenerated/function_enum.h (+1/-0)
src/runtime/booleans/BooleanImpl.cpp (+22/-13)
src/runtime/core/arithmetic_impl.cpp (+20/-16)
src/runtime/json/jsoniq_functions_impl.cpp (+25/-1)
src/runtime/json/pregenerated/jsoniq_functions.cpp (+25/-0)
src/runtime/json/pregenerated/jsoniq_functions.h (+32/-0)
src/runtime/pregenerated/iterator_enum.h (+1/-0)
src/runtime/spec/json/jsoniq_functions.xml (+36/-18)
src/runtime/spec/mappings.xml (+1/-1)
src/runtime/visitors/pregenerated/planiter_visitor.h (+7/-0)
src/runtime/visitors/pregenerated/printer_visitor.cpp (+15/-0)
src/runtime/visitors/pregenerated/printer_visitor.h (+5/-0)
src/store/naive/json_items.cpp (+4/-4)
src/store/naive/json_items.h (+1/-1)
src/store/naive/store.cpp (+7/-7)
src/store/naive/store.h (+4/-4)
src/types/casting.cpp (+2/-2)
src/types/root_typemanager.cpp (+25/-25)
src/types/root_typemanager.h (+5/-5)
src/zorbaserialization/serialize_zorba_types.cpp (+2/-2)
test/rbkt/ExpQueryResults/zorba/jsoniq/null02.xml.res (+1/-1)
test/rbkt/ExpQueryResults/zorba/jsoniq/null04.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/null05.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/null08.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-JNSE0022.xml.res (+1/-1)
test/rbkt/Queries/zorba/jsoniq/null01.xq (+1/-3)
test/rbkt/Queries/zorba/jsoniq/null02.xq (+1/-3)
test/rbkt/Queries/zorba/jsoniq/null03.xq (+1/-3)
test/rbkt/Queries/zorba/jsoniq/null04.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/null05.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/null06.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/null07.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/null08.xq (+10/-0)
Changed in zorba: | |
assignee: | nobody → Ghislain Fourny (gislenius) |
status: | New → Confirmed |
importance: | Undecided → Medium |
tags: | added: jsoniq |
Changed in zorba: | |
status: | Confirmed → In Progress |
Changed in zorba: | |
status: | In Progress → Fix Committed |
Changed in zorba: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
The specification now specifies behavior for:
- casting to and from null
- arithmetic operations involving null (meeting the above constraints)
- value comparison involving nulls (meeting the above constraints)
- general comparison involving nulls
If we have consensus, it needs to be implemented.