← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/markos-scratch into lp:zorba

 

Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.

Commit message:
implicit iteration for jsoniq rename exprs

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/181246

implicit iteration for jsoniq rename exprs
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/181246
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2013-08-14 16:34:05 +0000
+++ ChangeLog	2013-08-21 10:29:13 +0000
@@ -12,6 +12,16 @@
   * The grouping variable in a group by clause is now optional
   * New syntax for array lookup: expr1[[expr2]]
   * New jsoniq functions: jn:trim() and libjn:descendant-arrays()
+  * jsoniq extension: Object/array navigation allows item()* as the type of the
+    input sequence (doing implicit iteration over the input sequence and skipping
+    items that are not objects/arrays).
+  * jsoniq extension: Several of the jsoniq functions now allow item()* as the
+    type of the input sequence (doing implicit iteration over the input sequence
+    and skipping or simply propagating items that are not objects/arrays).
+  * jsoniq extension: implicit iteration is also done for jsoniq delete, renames,
+    and value replacements.
+  * jsoniq extension: EBV on jsoniq items now returns true (instead of raising
+    an error).
 
 Optimizations:
   * Implemented hoisting optimization for general FLWOR.
@@ -66,16 +76,9 @@
   * jn:keys function takes item()* as aparameter (instead of item())
   * Fixed bug #1189996 (Relocate some public API headers to util)
   * Fixed bug #1189790 (Update core module "full-text")
-  * Object/array navigation allows item()* as the type of the input sequence
-    (doing implicit iteration over the input sequence and skipping items
-     that are not objects/arrays).
-  * Several of the jsoniq functions now allow item()* as the type of the input
-    sequence (doing implicit iteration over the input sequence and skipping or
-    simply propagating items that are not objects/arrays).
   * Bug fix: selector value in object/array navigation is always cast to
     string/integer
   * The function jn:is-null() has been removed.
-  * EBV on jsoniq items now returns true (instead of raising an error).
   * Removed from libjn module the functions that existed in the jn module as well.
   * Renamed xqxq module to zorba-query module(zq module).
 

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2013-08-19 13:00:41 +0000
+++ src/compiler/translator/translator.cpp	2013-08-21 10:29:13 +0000
@@ -15291,19 +15291,19 @@
 
   std::vector<expr*> args(3);
 
-  args[0] = wrap_in_type_match(targetExpr,
-                               theRTM.JSON_OBJECT_TYPE_ONE,
-                               loc,
-                               TREAT_JSONIQ_OBJECT_UPDATE_TARGET, // JNUP0008
-                               NULL);
-
-  args[1] = wrap_in_type_promotion(nameExpr,
-                                   theRTM.STRING_TYPE_ONE,
-                                   PROMOTE_TYPE_PROMOTION);
-
-  args[2] = wrap_in_type_promotion(newNameExpr,
-                                   theRTM.STRING_TYPE_ONE,
-                                   PROMOTE_JSONIQ_OBJECT_SELECTOR); // JNUP0007
+  args[0] = targetExpr;
+
+  args[1] = create_cast_expr(nameExpr->get_loc(),
+                             nameExpr,
+                             theRTM.STRING_TYPE_ONE,
+                             true,
+                             true);
+
+  args[2] = create_cast_expr(newNameExpr->get_loc(),
+                             newNameExpr,
+                             theRTM.STRING_TYPE_ONE,
+                             false,
+                             true);
 
   fo_expr* updExpr = CREATE(fo)(theRootSctx,
                                 theUDF,

=== modified file 'src/functions/pregenerated/func_jsoniq_functions.cpp'
--- src/functions/pregenerated/func_jsoniq_functions.cpp	2013-08-19 13:00:41 +0000
+++ src/functions/pregenerated/func_jsoniq_functions.cpp	2013-08-21 10:29:13 +0000
@@ -504,8 +504,8 @@
       {
     DECL_WITH_KIND(sctx, op_zorba_json_rename,
         (createQName("http://zorba.io/internal/zorba-ops","","json-rename";), 
-        GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE, 
-        GENV_TYPESYSTEM.STRING_TYPE_ONE, 
+        GENV_TYPESYSTEM.ITEM_TYPE_STAR, 
+        GENV_TYPESYSTEM.STRING_TYPE_QUESTION, 
         GENV_TYPESYSTEM.STRING_TYPE_ONE, 
         GENV_TYPESYSTEM.EMPTY_TYPE),
         FunctionConsts::OP_ZORBA_JSON_RENAME_3);

=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp	2013-08-19 13:00:41 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp	2013-08-21 10:29:13 +0000
@@ -1871,8 +1871,8 @@
 
 /*******************************************************************************
   updating function op-zorba:object-rename(
-      $o as object(),
-      $name as xs:string, 
+      $o as item()*,
+      $name as xs:string?, 
       $newName as xs:string) 
 ********************************************************************************/
 bool JSONRenameIterator::nextImpl(
@@ -1887,17 +1887,22 @@
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
-  consumeNext(target, theChildren[0].getp(), planState);
-  consumeNext(name, theChildren[1].getp(), planState);
-  consumeNext(newName, theChildren[2].getp(), planState);
-
-  pul = GENV_ITEMFACTORY->createPendingUpdateList();
-
-  pul->addJSONObjectRename(&loc, target, name, newName);
-
-  result.transfer(pul);
-
-  STACK_PUSH(true, state);
+  if (consumeNext(name, theChildren[1].getp(), planState))
+  {
+    consumeNext(newName, theChildren[2].getp(), planState);
+
+    pul = GENV_ITEMFACTORY->createPendingUpdateList();
+
+    while(consumeNext(target, theChildren[0].getp(), planState))
+    {
+      if (target->isObject())
+        pul->addJSONObjectRename(&loc, target, name, newName);
+    }
+
+    result.transfer(pul);
+
+    STACK_PUSH(true, state);
+  }
 
   STACK_END(state);
 }

=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
--- src/runtime/spec/json/jsoniq_functions.xml	2013-08-19 13:00:41 +0000
+++ src/runtime/spec/json/jsoniq_functions.xml	2013-08-21 10:29:13 +0000
@@ -729,8 +729,8 @@
     <zorba:function>
 
       <zorba:signature localname="json-rename" prefix="op-zorba">
-        <zorba:param>object()</zorba:param>
-        <zorba:param>xs:string</zorba:param>
+        <zorba:param>item()*</zorba:param>
+        <zorba:param>xs:string?</zorba:param>
         <zorba:param>xs:string</zorba:param>
         <zorba:output>empty-sequence()</zorba:output>
       </zorba:signature>

=== modified file 'test/rbkt/Queries/zorba/jsoniq/jnty0007-5.spec'
--- test/rbkt/Queries/zorba/jsoniq/jnty0007-5.spec	2013-08-19 13:00:41 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jnty0007-5.spec	2013-08-21 10:29:13 +0000
@@ -1,1 +1,1 @@
-Error: http://www.w3.org/2005/xqt-errors:XPTY0004
+Error: http://jsoniq.org/errors:JNUP0016

=== removed file 'test/rbkt/Queries/zorba/jsoniq/jnty0008-8.spec'
--- test/rbkt/Queries/zorba/jsoniq/jnty0008-8.spec	2013-02-07 17:24:36 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jnty0008-8.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://jsoniq.org/errors:JNUP0008


Follow ups