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

Requested reviews:
  Markos Zaharioudakis (markos-za)

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

Fixed bug involving positional var and groupby 
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/90067
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-01-21 00:27:13 +0000
+++ ChangeLog	2012-01-25 10:26:26 +0000
@@ -22,6 +22,7 @@
   * Added createDayTimeDuration, createYearMonthDuration, createDocumentNode, createCommentNode, createPiNode to api's ItemFactory.
   * Added split function to the string module that allows for streamable tokenization but doesn't have regular expression
     support.
+  * Fixed bug involving positional var and groupby 
   * zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors
   * Add new XQuery interface for the PHP bindings.
   * Added API method Item::getNamespaceBindings().

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-01-11 17:30:25 +0000
+++ src/compiler/translator/translator.cpp	2012-01-25 10:26:26 +0000
@@ -1757,9 +1757,9 @@
 
   // Find the ordinal number of the "end-1" clause.
   int i;
-  for (i = (int)clauses.size () - 1; i >= 0; --i)
+  for (i = (int)clauses.size() - 1; i >= 0; --i)
   {
-    if (&*clauses [i] == end)
+    if (&*clauses[i] == end)
     {
       --i;
       break;
@@ -1772,17 +1772,26 @@
   {
     const FLWORClause& c = *clauses[i];
 
-    if (typeid (c) == typeid (ForClause))
+    if (typeid(c) == typeid(ForClause))
     {
-      const VarInDeclList& lV = *(static_cast<const ForClause*>(&c)->get_vardecl_list());
-      for (int j =  (int)lV.size() - 1; j >= 0; --j)
+      const VarInDeclList& varDecls = 
+      *(static_cast<const ForClause*>(&c)->get_vardecl_list());
+
+      for (int j =  (int)varDecls.size() - 1; j >= 0; --j)
       {
-        vars.insert(lookup_var(lV[j]->get_name(), loc, err::XPST0008));
+        VarInDecl* varDecl = varDecls[j].getp();
+
+        vars.insert(lookup_var(varDecl->get_name(), loc, err::XPST0008));
+
+        if (varDecl->get_posvar() != NULL)
+          vars.insert(lookup_var(varDecl->get_posvar()->get_name(), loc, err::XPST0008));
       }
     }
-    else if (typeid (c) == typeid (LetClause))
+    else if (typeid(c) == typeid(LetClause))
     {
-      const VarGetsDeclList& lV = *(static_cast<const LetClause*>(&c)->get_vardecl_list());
+      const VarGetsDeclList& lV = 
+      *(static_cast<const LetClause*>(&c)->get_vardecl_list());
+
       for (int j =  (int)lV.size() - 1; j >= 0; --j)
       {
         vars.insert(lookup_var(lV[j]->get_name(), loc, err::XPST0008));

=== added file 'test/rbkt/ExpQueryResults/zorba/groupby/posvar.xml.res'
--- test/rbkt/ExpQueryResults/zorba/groupby/posvar.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/groupby/posvar.xml.res	2012-01-25 10:26:26 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+12

=== added file 'test/rbkt/Queries/zorba/groupby/posvar.xq'
--- test/rbkt/Queries/zorba/groupby/posvar.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/groupby/posvar.xq	2012-01-25 10:26:26 +0000
@@ -0,0 +1,17 @@
+
+declare variable $sales :=
+<sales>
+<sale amount="1"><product id="1"/></sale>
+<sale amount="5"><product id="2"/></sale>
+<sale amount="7"><product id="2"/></sale>
+<sale amount="3"><product id="1"/></sale>
+</sales>;
+
+for $sale at $pos in $sales/sale
+let $prodid := $sale/product/@id
+group by $prodid
+where $pos = 3
+return sum($sale/@amount)
+
+
+

-- 
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