You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2016/08/08 03:45:09 UTC

vxquery git commit: VXQUERY-226: Fix key listing and array unboxing

Repository: vxquery
Updated Branches:
  refs/heads/master 5a69a4cb6 -> 4a19104c8


VXQUERY-226: Fix key listing and array unboxing


Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/4a19104c
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/4a19104c
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/4a19104c

Branch: refs/heads/master
Commit: 4a19104c8ad83b37a2ad9e70fcb3e3fccf883799
Parents: 5a69a4c
Author: riyafa <ri...@cse.mrt.ac.lk>
Authored: Fri Aug 5 22:49:23 2016 +0530
Committer: Preston Carman <pr...@apache.org>
Committed: Sun Aug 7 20:44:37 2016 -0700

----------------------------------------------------------------------
 .../xmlquery/translator/XMLQueryTranslator.java |  7 ++++-
 .../Array/Navigation/q07_array_navigation.txt   |  3 +++
 .../Object/Navigation/q08_object_navigation.txt |  2 ++
 .../Array/Navigation/q07_array_navigation.xq    | 23 ++++++++++++++++
 .../Object/Navigation/q08_object_navigation.xq  | 28 ++++++++++++++++++++
 .../Json/Parser/Partition-1/q14_parser.xq       |  2 +-
 .../Json/Parser/Partition-2/q15_parser.xq       |  2 +-
 .../Json/Parser/Partition-4/q16_parser.xq       |  2 +-
 .../cat/JsonArrayNavigationQueries.xml          |  5 ++++
 .../cat/JsonObjectNavigationQueries.xml         | 15 +++++++----
 10 files changed, 80 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
index bd150e0..ff230d3 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
@@ -1565,6 +1565,7 @@ public class XMLQueryTranslator {
                         for (ASTNode an : args) {
                             if (an.getTag() == ASTTag.ARGUMENT_LIST) {
                                 ArgumentListNode argNode = (ArgumentListNode) an;
+                                arguments.clear();
                                 for (ASTNode en : argNode.getArg()) {
                                     ILogicalExpression argument = vre(translateExpression(en, tCtx));
                                     arguments.add(argument);
@@ -1578,7 +1579,11 @@ public class XMLQueryTranslator {
                                     }
                                 }
                                 if (arguments.size() == 0) {
-                                    ctxExpr = sfce(BuiltinOperators.KEYS_OR_MEMBERS, expr);
+                                    if (ctxExpr == null) {
+                                        ctxExpr = sfce(BuiltinOperators.KEYS_OR_MEMBERS, expr);
+                                    } else {
+                                        ctxExpr = sfce(BuiltinOperators.KEYS_OR_MEMBERS, ctxExpr);
+                                    }
                                 }
                             } else {
                                 predicates = postfixNode.getArgs();

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/Navigation/q07_array_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/Navigation/q07_array_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/Navigation/q07_array_navigation.txt
new file mode 100644
index 0000000..5f5fbe7
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/Navigation/q07_array_navigation.txt
@@ -0,0 +1,3 @@
+1
+2
+3
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q08_object_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q08_object_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q08_object_navigation.txt
new file mode 100644
index 0000000..c4a4625
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q08_object_navigation.txt
@@ -0,0 +1,2 @@
+number
+letter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q07_array_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q07_array_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q07_array_navigation.xq
new file mode 100644
index 0000000..cf0fdba
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q07_array_navigation.xq
@@ -0,0 +1,23 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+   
+(: Json Array Navigation Query :)
+let $x := [
+    [ "mercury", [1, 2, 3], "venus", "earth", "mars" ],
+    [ "monday","tuesday", "wednesday", "thursday" ]
+]
+return $x(1)(2)()

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q08_object_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q08_object_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q08_object_navigation.xq
new file mode 100644
index 0000000..673e67a
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q08_object_navigation.xq
@@ -0,0 +1,28 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+
+(: Json Object Navigation :)
+let $x := {
+    "name" : {
+        "id" : {
+            "number" : 123,
+            "letter" : "g"
+        },
+        "first" : "Riyafa",
+        "Last" : "Abdul Hameed"}
+}
+return $x("name")("id")()

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q14_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q14_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q14_parser.xq
index 7bc86b6..9fff005 100644
--- a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q14_parser.xq
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q14_parser.xq
@@ -20,6 +20,6 @@
 let $x:="jsonCollection"
 for $r in collection($x)
     let $z:=$r("results")()
-    for $i in $z()  
+    for $i in $z
 where $i("date")="2001-01-01T00:00:00.000"
 return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q15_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q15_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q15_parser.xq
index b43ddc3..e6a0acb 100644
--- a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q15_parser.xq
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q15_parser.xq
@@ -20,6 +20,6 @@
 let $x:="json_half_1|json_half_2"
 for $r in collection($x)
     let $z:=$r("results")()
-    for $i in $z()  
+    for $i in $z
 where $i("datatype")="TMIN"
 return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q16_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q16_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q16_parser.xq
index 4fabd06..72388e8 100644
--- a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q16_parser.xq
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q16_parser.xq
@@ -20,6 +20,6 @@
 let $x:="json_quarter_1|json_quarter_2|json_quarter_3|json_quarter_4"
 for $r in collection($x)
     let $z:=$r("results")()
-    for $i in $z()  
+    for $i in $z
 where $i("station")="GHCND:US000000001"
 return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/cat/JsonArrayNavigationQueries.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/JsonArrayNavigationQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonArrayNavigationQueries.xml
index 808d0fb..44e1f64 100644
--- a/vxquery-xtest/src/test/resources/cat/JsonArrayNavigationQueries.xml
+++ b/vxquery-xtest/src/test/resources/cat/JsonArrayNavigationQueries.xml
@@ -50,4 +50,9 @@
         <query name="q06_array_navigation" date="2016-07-12"/>
         <output-file compare="Text">q06_array_navigation.txt</output-file>
     </test-case>
+    <test-case name="json-array-navigation-q07" FilePath="Json/Array/Navigation" Creator="Riyafa Abdul Hameed">
+        <description>Navigate through an array</description>
+        <query name="q07_array_navigation" date="2016-08-05"/>
+        <output-file compare="Text">q07_array_navigation.txt</output-file>
+    </test-case>
 </test-group>

http://git-wip-us.apache.org/repos/asf/vxquery/blob/4a19104c/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml
index 0fe4447..7313a8c 100644
--- a/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml
+++ b/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml
@@ -32,28 +32,33 @@
         <output-file compare="Text">q02_object_navigation.txt</output-file>
     </test-case>
     <test-case name="json-object-navigation-q03" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
-        <description>Size of an object.</description>
+        <description>Navigate through an object.</description>
         <query name="q03_object_navigation" date="2016-06-25"/>
         <output-file compare="Text">q03_object_navigation.txt</output-file>
     </test-case>
     <test-case name="json-object-navigation-q04" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
-        <description>Navigate through an empty object.</description>
+        <description>List keys of the object.</description>
         <query name="q04_object_navigation" date="2016-06-25"/>
         <output-file compare="Text">q04_object_navigation.txt</output-file>
     </test-case>
     <test-case name="json-object-navigation-q05" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
-        <description>Ask for an index out of the object size.</description>
+        <description>Navigate through an empty object.</description>
         <query name="q05_object_navigation" date="2016-06-25"/>
         <output-file compare="Text">q05_object_navigation.txt</output-file>
     </test-case>
     <test-case name="json-object-navigation-q06" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
-        <description>Ask for an index out of the object size.</description>
+        <description>Navigate through an empty object</description>
         <query name="q06_object_navigation" date="2016-06-25"/>
         <output-file compare="Text">q06_object_navigation.txt</output-file>
     </test-case>
     <test-case name="json-object-navigation-q07" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
-        <description>Ask for an index out of the object size.</description>
+        <description>List non existing key</description>
         <query name="q07_object_navigation" date="2016-06-25"/>
         <output-file compare="Text">q07_object_navigation.txt</output-file>
     </test-case>
+    <test-case name="json-object-navigation-q08" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
+        <description>Navigate through an object</description>
+        <query name="q08_object_navigation" date="2016-08-05"/>
+        <output-file compare="Text">q08_object_navigation.txt</output-file>
+    </test-case>
 </test-group>