Matthias Brantner has proposed merging 
lp:~zorba-coders/zorba/feature-compare_null into lp:zorba.

Commit message:
null is smaller than any other atomic value type

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Ghislain Fourny (gislenius)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/feature-compare_null/+merge/157008
-- 
https://code.launchpad.net/~zorba-coders/zorba/feature-compare_null/+merge/157008
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/booleans/BooleanImpl.cpp'
--- src/runtime/booleans/BooleanImpl.cpp	2013-03-26 00:17:06 +0000
+++ src/runtime/booleans/BooleanImpl.cpp	2013-04-04 01:39:25 +0000
@@ -997,6 +997,15 @@
       {
         return item0->getIntegerValue().compare(item1->getIntegerValue());
       }
+      // jn:null is always smaller than any other atomic value type
+      else if (TypeOps::is_subtype(type0, store::JS_NULL))
+      {
+        return -1;
+      }
+      else if (TypeOps::is_subtype(type1, store::JS_NULL))
+      {
+        return 1;
+      }
       else
       {
         xqtref_t type0 = tm->create_value_type(item0.getp());
@@ -1009,8 +1018,7 @@
   }
   catch(const ZorbaException& e)
   {
-    // For example, two QName or null items do not have
-    // an order relationship.
+    // For example, two QName items do not have an order relationship.
     if (e.diagnostic() == zerr::ZSTR0040_TYPE_ERROR)
     {
       xqtref_t type0 = tm->create_value_type(item0.getp());

=== modified file 'src/store/naive/json_items.h'
--- src/store/naive/json_items.h	2013-03-24 20:40:03 +0000
+++ src/store/naive/json_items.h	2013-04-04 01:39:25 +0000
@@ -82,6 +82,14 @@
 
   uint32_t hash(long timezone = 0, const XQPCollator* aCollation = 0) const;
 
+  long compare(const store::Item* i, long tz = 0, const XQPCollator* c = 0) const
+  {
+    if (i->getTypeCode() == store::JS_NULL)
+      return 0;
+    else
+      return -1;
+  }
+
   bool getEBV() const { return false; }
 };
 

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/null07.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/null07.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/null07.xml.res	2013-04-04 01:39:25 +0000
@@ -0,0 +1,1 @@
+false

=== modified file 'test/rbkt/ExpQueryResults/zorba/jsoniq/null09.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/null09.xml.res	2013-03-26 00:17:06 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/null09.xml.res	2013-04-04 01:39:25 +0000
@@ -1,1 +1,1 @@
-false false false true
+false false false true false false

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/orderby01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/orderby01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/orderby01.xml.res	2013-04-04 01:39:25 +0000
@@ -0,0 +1,1 @@
+{ "foo" : null }{ "foo" : null }{ "foo" : 1 }{ "foo" : 42 }

=== removed file 'test/rbkt/Queries/zorba/jsoniq/null07.spec'
--- test/rbkt/Queries/zorba/jsoniq/null07.spec	2013-03-24 19:06:30 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null07.spec	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
-Error: http://www.w3.org/2005/xqt-errors:XPTY0004
-

=== modified file 'test/rbkt/Queries/zorba/jsoniq/null09.jq'
--- test/rbkt/Queries/zorba/jsoniq/null09.jq	2013-03-26 00:17:06 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null09.jq	2013-04-04 01:39:25 +0000
@@ -1,1 +1,1 @@
-null eq 1, null eq current-dateTime(), null ne null, null ne 42
+null eq 1, null eq current-dateTime(), null ne null, null ne 42, 1 lt null, null lt null

=== added file 'test/rbkt/Queries/zorba/jsoniq/orderby01.jq'
--- test/rbkt/Queries/zorba/jsoniq/orderby01.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/orderby01.jq	2013-04-04 01:39:25 +0000
@@ -0,0 +1,7 @@
+for $seq in (
+  { "foo" : 1 },
+  { "foo" : 42 },
+  { "foo" : null },
+  { "foo" : () } )
+order by $seq.foo
+return $seq

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to