Skip to content

Commit d296b88

Browse files
updates to woql language
1 parent e697f64 commit d296b88

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

lib/woql.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ WOQL.lower = function(u, l){ return new WOQLQuery().lower(u, l); }
4848
WOQL.pad = function(input, pad, len, output){ return new WOQLQuery().pad(input, pad, len, output); }
4949
WOQL.join = function(...list){ return new WOQLQuery().join(...list); }
5050
WOQL.unique = function(prefix, vari, type){ return new WOQLQuery().unique(prefix, vari, type); }
51+
WOQL.idgen = function(prefix, vari, type, output){ return new WOQLQuery().idgen(prefix, vari, type, output); }
52+
WOQL.typecast = function(vara, type, varb){ return new WOQLQuery().typecast(vara, type, varb); }
53+
5154

5255
/* Mathematical Processing */
5356
WOQL.eval = function(arith, v){ return new WOQLQuery().eval(arith, v);}
@@ -147,6 +150,10 @@ WOQLQuery.prototype.buildAsClauses = function(vars, cols){
147150
return clauses;
148151
}
149152

153+
WOQLQuery.prototype.typecast = function(va, type, vb){
154+
this.cursor['typecast'] = [va, type, vb];
155+
return this;
156+
}
150157

151158

152159
WOQLQuery.prototype.remote = function(json){
@@ -189,6 +196,24 @@ WOQLQuery.prototype.group_by = function(gvarlist, groupedvar, groupquery, output
189196
return this;
190197
}
191198

199+
WOQLQuery.prototype.idgen = function(prefix, vari, type, mode){
200+
this.cursor['idgen'] = [prefix];
201+
if(vari.json){
202+
this.cursor['idgen'].push(vari.json());
203+
}
204+
else if(vari.list){
205+
this.cursor['idgen'].push(vari);
206+
}
207+
else {
208+
this.cursor['idgen'].push({"list": vari})
209+
}
210+
if(mode){
211+
this.cursor['idgen'].push(mode);
212+
}
213+
this.cursor['idgen'].push(type);
214+
return this;
215+
}
216+
192217

193218
WOQLQuery.prototype.unique = function(prefix, vari, type){
194219
this.cursor['unique'] = [prefix];
@@ -209,6 +234,13 @@ WOQLQuery.prototype.unique = function(prefix, vari, type){
209234
WOQLQuery.prototype.concat = function(list, v){
210235
if(typeof list == "string"){
211236
var nlist = list.split(/(v:[\w_]+)\b/);
237+
var nxlist = [];
238+
for(var i = 1; i<nlist.length; i++){
239+
if(nlist[i-1].substring(nlist[i-1].length-1) == "v" && nlist[i].substring(0, 1) == ":"){
240+
nlist[i-1] = nlist[i-1].substring(0, nlist[i-1].length-1);
241+
nlist[i] = nlist[i].substring(1);
242+
}
243+
}
212244
}
213245
else if(list.list){
214246
var nlist = list.list;

0 commit comments

Comments
 (0)