Skip to content

Commit 67ff00e

Browse files
Adding Marshalling lists correctly.
1 parent 05ba853 commit 67ff00e

File tree

4 files changed

+42
-34
lines changed

4 files changed

+42
-34
lines changed

lib/query/woqlCore.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ WOQLQuery.prototype.cleanDataValue = function(o, t) {
338338
} else if (typeof o == 'boolean') {
339339
t = t || 'xsd:boolean'
340340
obj['data'] = this.jlt(o, t)
341+
} else if (Array.isArray(o)) {
342+
let res = []
343+
for( var i = 0; i < o.length; i++ ){
344+
res.push(this.cleanDataValue(o[i]))
345+
}
346+
obj['list'] = res
341347
} else if (typeof o == 'object' && o) {
342348
if (o['@value']) obj['data'] = o
343349
else return o

lib/query/woqlQuery.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ WOQLQuery.prototype.unique = function(prefix, vari, type) {
647647
if (this.cursor['@type']) this.wrapCursorWithAnd()
648648
this.cursor['@type'] = 'HashKey'
649649
this.cursor['base'] = this.cleanDataValue(prefix,'xsd:string')
650-
this.cursor['key_list'] = this.dataList(vari)
650+
this.cursor['key_list'] = this.cleanDataValue(vari)
651651
this.cursor['uri'] = this.cleanNodeValue(type)
652652
return this
653653
}
@@ -713,7 +713,7 @@ WOQLQuery.prototype.split = function(input, glue, output) {
713713
this.cursor['@type'] = 'Split'
714714
this.cursor['string'] = this.cleanDataValue(input)
715715
this.cursor['pattern'] = this.cleanDataValue(glue)
716-
this.cursor['list'] = this.dataList(output)
716+
this.cursor['list'] = this.cleanDataValue(output)
717717
return this
718718
}
719719

@@ -748,7 +748,7 @@ WOQLQuery.prototype.concat = function(list, v) {
748748
if (Array.isArray(list)) {
749749
if (this.cursor['@type']) this.wrapCursorWithAnd()
750750
this.cursor['@type'] = 'Concatenate'
751-
this.cursor['list'] = this.dataList(list, true)
751+
this.cursor['list'] = this.cleanDataValue(list, true)
752752
this.cursor['result'] = this.cleanDataValue(v)
753753
}
754754
return this
@@ -761,7 +761,7 @@ WOQLQuery.prototype.join = function(input, glue, output) {
761761
//return ['join_list', 'join_separator', 'join']
762762
if (this.cursor['@type']) this.wrapCursorWithAnd()
763763
this.cursor['@type'] = 'Join'
764-
this.cursor['list'] = this.dataList(input)
764+
this.cursor['list'] = this.cleanDataValue(input)
765765
this.cursor['separator'] = this.cleanDataValue(glue)
766766
this.cursor['result'] = this.cleanDataValue(output)
767767
return this
@@ -771,7 +771,7 @@ WOQLQuery.prototype.sum = function(input, output) {
771771
//if (input && input == 'args') return ['sum_list', 'sum']
772772
if (this.cursor['@type']) this.wrapCursorWithAnd()
773773
this.cursor['@type'] = 'Sum'
774-
this.cursor['list'] = this.dataList(input)
774+
this.cursor['list'] = this.cleanDataValue(input)
775775
this.cursor['result'] = this.cleanObject(output)
776776
return this
777777
}
@@ -799,7 +799,7 @@ WOQLQuery.prototype.re = function(p, s, m) {
799799
this.cursor['@type'] = 'Regexp'
800800
this.cursor['pattern'] = this.cleanDataValue(p)
801801
this.cursor['string'] = this.cleanDataValue(s)
802-
this.cursor['result'] = this.dataList(m)
802+
this.cursor['result'] = this.cleanDataValue(m)
803803
return this
804804
}
805805

@@ -810,7 +810,7 @@ WOQLQuery.prototype.length = function(va, vb) {
810810
//return ['length_list', 'length']
811811
if (this.cursor['@type']) this.wrapCursorWithAnd()
812812
this.cursor['@type'] = 'Length'
813-
this.cursor['list'] = this.cleanObject(va)
813+
this.cursor['list'] = this.cleanDataValue(va)
814814
if (typeof vb == 'number') {
815815
this.cursor['length'] = this.cleanObject(vb, 'xsd:nonNegativeInteger')
816816
} else if (typeof vb == 'string') {

test/woqlJson/woqlConcatJson.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
module.exports={
22
"@type": "Concatenate",
3-
"list": [
4-
{
5-
"@type": "DataValue",
6-
"variable": "Duration"
7-
},
8-
{
9-
"@type": "DataValue",
10-
"data": {
11-
"@type": "xsd:string",
12-
"@value": " yo "
13-
}
14-
},
15-
{
16-
"@type": "DataValue",
17-
"variable": "Duration_Cast"
18-
}
19-
],
3+
"list": { "@type" : "DataValue",
4+
"list" : [
5+
{
6+
"@type": "DataValue",
7+
"variable": "Duration"
8+
},
9+
{
10+
"@type": "DataValue",
11+
"data": {
12+
"@type": "xsd:string",
13+
"@value": " yo "
14+
}
15+
},
16+
{
17+
"@type": "DataValue",
18+
"variable": "Duration_Cast"
19+
}
20+
]},
2021
"result": {
2122
"@type": "DataValue",
2223
"data": {

test/woqlJson/woqlJoinSplitJson.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
module.exports={joinJson:{
22
"@type": "Join",
3-
"list": [
4-
{
5-
"@type": "DataValue",
6-
"variable": "A_obj"
7-
},
8-
{
9-
"@type": "DataValue",
10-
"variable": "B_obj"
11-
}
12-
],
3+
"list": { "@type" : "DataValue",
4+
"list" : [
5+
{
6+
"@type": "DataValue",
7+
"variable": "A_obj"
8+
},
9+
{
10+
"@type": "DataValue",
11+
"variable": "B_obj"
12+
}
13+
]},
1314
"separator": {
1415
"@type": "DataValue",
1516
"data": {

0 commit comments

Comments
 (0)