← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/fix-1046410 into lp:zorba

 

Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/fix-1046410 into lp:zorba.

Requested reviews:
  Chris Hillery (ceejatec)
  Matthias Brantner (matthias-brantner)
Related bugs:
  Bug #1046410 in Zorba: "jsoniq: pair value is ()"
  https://bugs.launchpad.net/zorba/+bug/1046410
  Bug #1046411 in Zorba: "jsoniq: pair value returns more then one item"
  https://bugs.launchpad.net/zorba/+bug/1046411

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-1046410/+merge/123285

Fixed bug 1046410 and 1046411.
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-1046410/+merge/123285
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-09-05 12:22:23 +0000
+++ ChangeLog	2012-09-07 14:13:43 +0000
@@ -25,7 +25,8 @@
   * Fixed bug #1042840 (qname pool free-list corruption)
   * Fixed bug #866984 (better error message for an eval error)
   * Fixed bug #932884 (HTML and XHTML serialization of empty elements)
-	
+  * Fixed bug #1046410 (zero or more than one item in a pair value)
+
 version 2.6
 
 New Features:

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-08-31 12:40:20 +0000
+++ src/compiler/translator/translator.cpp	2012-09-07 14:13:43 +0000
@@ -11371,15 +11371,6 @@
                       PromoteIterator::JSONIQ_PAIR_NAME, // JNTY0001
                       NULL);
 
-  valueExpr = theExprManager->
-  create_treat_expr(theRootSctx,
-                    valueExpr->get_loc(),
-                    valueExpr,
-                    GENV_TYPESYSTEM.ITEM_TYPE_ONE,
-                    TreatIterator::JSONIQ_VALUE, // JNTY0002
-                    false,
-                    NULL);
-
   push_nodestack(valueExpr);
   push_nodestack(nameExpr);
 #endif

=== modified file 'src/runtime/json/json_constructors.cpp'
--- src/runtime/json/json_constructors.cpp	2012-04-17 09:43:45 +0000
+++ src/runtime/json/json_constructors.cpp	2012-09-07 14:13:43 +0000
@@ -292,6 +292,8 @@
     std::vector<store::Item_t> values(numPairs);
     store::Item_t name;
     store::Item_t value;
+    store::Item_t lValueItem;
+    std::vector<store::Item_t> lValuesTemp;
 
     store::CopyMode copymode;
     copymode.set(true,
@@ -302,11 +304,29 @@
     for (csize i = 0; i < numPairs; ++i)
     {
       consumeNext(name, theChildren[i], planState);
-      consumeNext(value, theChildren[numPairs + i], planState);
-
-      if (theCopyInputs[i] && (value->isNode() || value->isJSONItem()))
-        value = value->copy(NULL, copymode);
-
+      
+      lValuesTemp.clear();
+      for (bool lSuccess = consumeNext(lValueItem, theChildren[numPairs + i], planState);
+           lSuccess;
+           lSuccess = consumeNext(lValueItem, theChildren[numPairs + i], planState))
+      {
+        if (theCopyInputs[i] && (lValueItem->isNode() || lValueItem->isJSONItem()))
+        {
+          lValueItem = lValueItem->copy(NULL, copymode);
+        }
+        lValuesTemp.push_back(lValueItem);
+      }
+      switch (lValuesTemp.size())
+      {
+        case 0 :
+          GENV_ITEMFACTORY->createJSONNull(value);
+          break;
+        case 1 :
+          value = lValuesTemp[0];
+          break;
+        default :
+          GENV_ITEMFACTORY->createJSONArray(value, lValuesTemp);
+      }
       names[i].transfer(name);
       values[i].transfer(value);
     }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/pair-value-more-than-one.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/pair-value-more-than-one.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/pair-value-more-than-one.xml.res	2012-09-07 14:13:43 +0000
@@ -0,0 +1,1 @@
+{ "foo" : [ "bar", "bar" ] }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/pair-value-null.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/pair-value-null.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/pair-value-null.xml.res	2012-09-07 14:13:43 +0000
@@ -0,0 +1,1 @@
+{ "foo" : null }

=== removed file 'test/rbkt/Queries/zorba/jsoniq/jnty0002-1.spec'
--- test/rbkt/Queries/zorba/jsoniq/jnty0002-1.spec	2012-06-19 14:58:25 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jnty0002-1.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://www.jsoniq.org/errors:JNTY0002

=== removed file 'test/rbkt/Queries/zorba/jsoniq/jnty0002-1.xq'
--- test/rbkt/Queries/zorba/jsoniq/jnty0002-1.xq	2012-06-19 14:58:25 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jnty0002-1.xq	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
-{ "foo" : ("bar", "bar") }
-

=== removed file 'test/rbkt/Queries/zorba/jsoniq/jnty0002-2.spec'
--- test/rbkt/Queries/zorba/jsoniq/jnty0002-2.spec	2012-06-19 14:58:25 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jnty0002-2.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://www.jsoniq.org/errors:JNTY0002

=== removed file 'test/rbkt/Queries/zorba/jsoniq/jnty0002-2.xq'
--- test/rbkt/Queries/zorba/jsoniq/jnty0002-2.xq	2012-06-19 14:58:25 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jnty0002-2.xq	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
-{ "foo" : () }
-

=== added file 'test/rbkt/Queries/zorba/jsoniq/pair-value-more-than-one.xq'
--- test/rbkt/Queries/zorba/jsoniq/pair-value-more-than-one.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/pair-value-more-than-one.xq	2012-09-07 14:13:43 +0000
@@ -0,0 +1,2 @@
+{ "foo" : ("bar", "bar") }
+

=== added file 'test/rbkt/Queries/zorba/jsoniq/pair-value-null.xq'
--- test/rbkt/Queries/zorba/jsoniq/pair-value-null.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/pair-value-null.xq	2012-09-07 14:13:43 +0000
@@ -0,0 +1,2 @@
+{ "foo" : () }
+


Follow ups