File tree Expand file tree Collapse file tree 2 files changed +70
-1
lines changed
test/test-suite/groups/array-constructor Expand file tree Collapse file tree 2 files changed +70
-1
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,8 @@ var jsonata = (function() {
219219 }
220220
221221 if ( expr . keepSingletonArray ) {
222- if ( ! isSequence ( resultSequence ) ) {
222+ // if the array is explicitly constructed in the expression and marked to promote singleton sequences to array
223+ if ( Array . isArray ( resultSequence ) && resultSequence . cons && ! resultSequence . sequence ) {
223224 resultSequence = createSequence ( resultSequence ) ;
224225 }
225226 resultSequence . keepSingleton = true ;
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "expr" : " $.[value,epochSeconds][]" ,
4+ "data" : [
5+ {
6+ "epochSeconds" : 1578381600 ,
7+ "value" : 3
8+ },
9+ {
10+ "epochSeconds" : 1578381700 ,
11+ "value" : 5
12+ }
13+ ],
14+ "bindings" : {},
15+ "result" : [
16+ [3 , 1578381600 ],
17+ [5 , 1578381700 ]
18+ ]
19+ },
20+ {
21+ "expr" : " $.[value,epochSeconds][]" ,
22+ "data" : [
23+ {
24+ "epochSeconds" : 1578381600 ,
25+ "value" : 3
26+ }
27+ ],
28+ "bindings" : {},
29+ "result" : [
30+ [3 , 1578381600 ]
31+ ]
32+ },
33+ {
34+ "expr" : " $.[value,epochSeconds]" ,
35+ "data" : [
36+ {
37+ "epochSeconds" : 1578381600 ,
38+ "value" : 3
39+ }
40+ ],
41+ "bindings" : {},
42+ "result" : [3 , 1578381600 ]
43+ },
44+ {
45+ "expr" : " singleArray" ,
46+ "data" : {
47+ "singleArray" : [{"foo" :" bar" }]
48+ },
49+ "bindings" : {},
50+ "result" : [
51+ {
52+ "foo" : " bar"
53+ }
54+ ]
55+ },
56+ {
57+ "expr" : " singleArray[]" ,
58+ "data" : {
59+ "singleArray" : [{"foo" :" bar" }]
60+ },
61+ "bindings" : {},
62+ "result" : [
63+ {
64+ "foo" : " bar"
65+ }
66+ ]
67+ }
68+ ]
You can’t perform that action at this time.
0 commit comments