Changeset: 159672d0af34 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/159672d0af34
Modified Files:
        monetdb5/modules/atoms/Tests/json13.maltest
        monetdb5/modules/atoms/json.c
Branch: default
Log Message:

Return a list when jsonpath contains * operator


diffs (34 lines):

diff --git a/monetdb5/modules/atoms/Tests/json13.maltest 
b/monetdb5/modules/atoms/Tests/json13.maltest
--- a/monetdb5/modules/atoms/Tests/json13.maltest
+++ b/monetdb5/modules/atoms/Tests/json13.maltest
@@ -53,7 +53,7 @@ p:= json.filter(js,".store.*")
 query T rowsort
 io.print(p)
 ----
-"[{ \"category\": \"reference\", \"author\": \"Nigel Rees\", \"title\": 
\"Sayings of the Century\", \"price\": 8.95 }, { \"category\": \"fiction\", 
\"author\": \"Evelyn Waugh\", \"title\": \"Sword of Honour\", \"price\": 12.99 
}, { \"category\": \"fiction\", \"author\": \"Herman Melville\", \"title\": 
\"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 8.99 }, { \"category\": 
\"fiction\", \"author\": \"J. R. R. Tolkien\", \"title\": \"The Lord of the 
Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 22.99 },{ \"color\": \"red\", 
\"price\": 19.95 }]"
+"[[ { \"category\": \"reference\", \"author\": \"Nigel Rees\", \"title\": 
\"Sayings of the Century\", \"price\": 8.95 }, { \"category\": \"fiction\", 
\"author\": \"Evelyn Waugh\", \"title\": \"Sword of Honour\", \"price\": 12.99 
}, { \"category\": \"fiction\", \"author\": \"Herman Melville\", \"title\": 
\"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 8.99 }, { \"category\": 
\"fiction\", \"author\": \"J. R. R. Tolkien\", \"title\": \"The Lord of the 
Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 22.99 } ],{ \"color\": 
\"red\", \"price\": 19.95 }]"
 
 statement ok
 p:= json.filter(js,".store..price")
@@ -93,5 +93,5 @@ p:= json.filter(js,"$")
 query T rowsort
 io.print(p)
 ----
-"[{ \"store\": { \"book\": [ { \"category\": \"reference\", \"author\": 
\"Nigel Rees\", \"title\": \"Sayings of the Century\", \"price\": 8.95 }, { 
\"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\": \"Sword of 
Honour\", \"price\": 12.99 }, { \"category\": \"fiction\", \"author\": \"Herman 
Melville\", \"title\": \"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 
8.99 }, { \"category\": \"fiction\", \"author\": \"J. R. R. Tolkien\", 
\"title\": \"The Lord of the Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 
22.99 } ], \"bicycle\": { \"color\": \"red\", \"price\": 19.95 } } }]"
+"{ \"store\": { \"book\": [ { \"category\": \"reference\", \"author\": \"Nigel 
Rees\", \"title\": \"Sayings of the Century\", \"price\": 8.95 }, { 
\"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\": \"Sword of 
Honour\", \"price\": 12.99 }, { \"category\": \"fiction\", \"author\": \"Herman 
Melville\", \"title\": \"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 
8.99 }, { \"category\": \"fiction\", \"author\": \"J. R. R. Tolkien\", 
\"title\": \"The Lord of the Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 
22.99 } ], \"bicycle\": { \"color\": \"red\", \"price\": 19.95 } } }"
 
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -845,9 +845,9 @@ JSONfilterInternal(json *ret, json *js, 
                // pattern contains the .. operator
                if (terms[i].token == ANY_STEP ||
                        // pattern contains the [*] operator
-                       (terms[i].token == CHILD_STEP && terms[i].index == 
INT_MAX && terms[i].name == NULL)) {
+                       (terms[i].token == CHILD_STEP && terms[i].index == 
INT_MAX && terms[i].name == NULL) ||
+                       (terms[i].token == CHILD_STEP && terms[i].index == 
INT_MAX && *terms[i].name == '*')) {
 
-               /* if (terms[i].make_array) { */
                        return_array = true;
                        break;
                }
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to