Skip to content

Commit a569f7b

Browse files
Typos in list conversion
1 parent 353c062 commit a569f7b

File tree

2 files changed

+23
-36
lines changed

2 files changed

+23
-36
lines changed

lib/query/woqlCore.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,12 @@ WOQLQuery.prototype.arop = function(arg) {
190190
* takes input that can be either a string (variable name)
191191
* or an array - each element of the array is a member of the list
192192
*/
193-
WOQLQuery.prototype.wlist = function(wvar, string_only) {
193+
WOQLQuery.prototype.dataList = function(wvar, string_only) {
194194
if (typeof wvar == 'string') return this.expandDataVariable(wvar, true)
195195
if (Array.isArray(wvar)) {
196196
let ret = []
197197
for (var i = 0; i < wvar.length; i++) {
198198
let co = this.cleanDataValue(wvar[i])
199-
if (typeof co == 'string') co = {node: co}
200199
ret.push(co)
201200
}
202201
return ret

lib/query/woqlQuery.js

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ WOQLQuery.prototype.from = function(graph_filter, query) {
141141
'The first parameter to from must be a Graph Filter Expression (string)',
142142
)
143143
}
144-
this.cursor['graph_filter'] = this.jlt(graph_filter)
144+
this.cursor['graph_filter'] = graph_filter
145145
return this.addSubQuery(query)
146146
}
147147

@@ -185,7 +185,7 @@ WOQLQuery.prototype.removed_triple = function(a, b, c) {
185185
//if (a && a == 'args')
186186
//return ['subject', 'predicate', 'object']
187187
if (this.cursor['@type']) this.wrapCursorWithAnd()
188-
this.cursor['@type'] = 'RemovedTriple'
188+
this.cursor['@type'] = 'DeletedTriple'
189189
this.cursor['subject'] = this.cleanSubject(a)
190190
this.cursor['predicate'] = this.cleanPredicate(b)
191191
this.cursor['object'] = this.cleanObject(c)
@@ -271,11 +271,11 @@ WOQLQuery.prototype.substr = function(String, Before, Length, After, SubString)
271271
)
272272
if (this.cursor['@type']) this.wrapCursorWithAnd()
273273
this.cursor['@type'] = 'Substring'
274-
this.cursor['string'] = this.cleanObject(String)
275-
this.cursor['before'] = this.cleanObject(Before, 'xsd:nonNegativeInteger')
276-
this.cursor['length'] = this.cleanObject(Length, 'xsd:nonNegativeInteger')
277-
this.cursor['after'] = this.cleanObject(After, 'xsd:nonNegativeInteger')
278-
this.cursor['substring'] = this.cleanObject(SubString)
274+
this.cursor['string'] = this.cleanDataValue(String, 'xsd:string')
275+
this.cursor['before'] = this.cleanDataValue(Before, 'xsd:nonNegativeInteger')
276+
this.cursor['length'] = this.cleanDataValue(Length, 'xsd:nonNegativeInteger')
277+
this.cursor['after'] = this.cleanDataValue(After, 'xsd:nonNegativeInteger')
278+
this.cursor['substring'] = this.cleanDataValue(SubString, 'xsd:string')
279279
return this
280280
}
281281

@@ -714,7 +714,7 @@ WOQLQuery.prototype.split = function(input, glue, output) {
714714
this.cursor['@type'] = 'Split'
715715
this.cursor['string'] = this.cleanDataValue(input)
716716
this.cursor['pattern'] = this.cleanDataValue(glue)
717-
this.cursor['list'] = this.wlist(output)
717+
this.cursor['list'] = this.dataList(output)
718718
return this
719719
}
720720

@@ -749,7 +749,7 @@ WOQLQuery.prototype.concat = function(list, v) {
749749
if (Array.isArray(list)) {
750750
if (this.cursor['@type']) this.wrapCursorWithAnd()
751751
this.cursor['@type'] = 'Concatenate'
752-
this.cursor['list'] = this.wlist(list, true)
752+
this.cursor['list'] = this.dataList(list, true)
753753
this.cursor['result'] = this.cleanDataValue(v)
754754
}
755755
return this
@@ -762,7 +762,7 @@ WOQLQuery.prototype.join = function(input, glue, output) {
762762
//return ['join_list', 'join_separator', 'join']
763763
if (this.cursor['@type']) this.wrapCursorWithAnd()
764764
this.cursor['@type'] = 'Join'
765-
this.cursor['list'] = this.wlist(input)
765+
this.cursor['list'] = this.dataList(input)
766766
this.cursor['separator'] = this.cleanDataValue(glue)
767767
this.cursor['result'] = this.cleanDataValue(output)
768768
return this
@@ -772,7 +772,7 @@ WOQLQuery.prototype.sum = function(input, output) {
772772
//if (input && input == 'args') return ['sum_list', 'sum']
773773
if (this.cursor['@type']) this.wrapCursorWithAnd()
774774
this.cursor['@type'] = 'Sum'
775-
this.cursor['list'] = this.wlist(input)
775+
this.cursor['list'] = this.dataList(input)
776776
this.cursor['result'] = this.cleanObject(output)
777777
return this
778778
}
@@ -800,7 +800,7 @@ WOQLQuery.prototype.re = function(p, s, m) {
800800
this.cursor['@type'] = 'Regexp'
801801
this.cursor['pattern'] = this.cleanDataValue(p)
802802
this.cursor['string'] = this.cleanDataValue(s)
803-
this.cursor['result'] = this.wlist(m)
803+
this.cursor['result'] = this.dataList(m)
804804
return this
805805
}
806806

@@ -893,26 +893,17 @@ WOQLQuery.prototype.order_by = function(...orderedVarlist) {
893893
? orderedVarlist.pop()
894894
: false
895895

896-
let vars = []
897-
898896
for (var i = 0; i < orderedVarlist.length; i++) {
899-
if (orderedVarlist[i] == 'asc') {
900-
vars[vars.length - 1]['order'] = 'asc'
901-
} else if (orderedVarlist[i] == 'desc') {
902-
vars[vars.length - 1]['order'] = 'desc'
903-
} else if (typeof orderedVarlist[i] == 'string') {
904-
vars.push({varname: orderedVarlist[i], order: 'asc'})
905-
} else {
906-
vars.push(orderedVarlist[i])
907-
}
908-
}
909-
for (var i = 0; i < vars.length; i++) {
910-
let obj = {
911-
'@type': 'OrderTemplate',
912-
'variable': this.rawVar(vars[i].varname),
913-
'order': vars[i].order
897+
if (typeof orderedVarlist[i] == 'string'){
898+
let obj = {
899+
'@type': 'OrderTemplate',
900+
'variable': this.rawVar(orderedVarlist[i]),
901+
'order': "asc"
902+
}
903+
this.cursor['ordering'].push(obj)
904+
}else{
905+
this.cursor['ordering'].push(orderedVarlist[i])
914906
}
915-
this.cursor['ordering'].push(obj)
916907
}
917908
return this.addSubQuery(embedquery)
918909
}
@@ -926,11 +917,8 @@ WOQLQuery.prototype.group_by = function(gvarlist, groupedvar, output, groupquery
926917

927918
if (typeof gvarlist == 'string') gvarlist = [gvarlist]
928919
this.cursor['group_by'] = this.rawVarList(gvarlist)
929-
if (typeof groupedvar == 'string') {
930-
this.cursor['template'] = this.varj(groupedvar)
931-
} else {
920+
if (typeof groupedvar == 'string') groupedvar = [groupedvar]
932921
this.cursor['template'] = this.rawVarList(groupedvar)
933-
}
934922
this.cursor['grouped'] = this.varj(output)
935923
return this.addSubQuery(groupquery)
936924
}

0 commit comments

Comments
 (0)