@@ -51,6 +51,9 @@ WOQL.unique = function(prefix, vari, type){ return new WOQLQuery().unique(prefix
51
51
WOQL . idgen = function ( prefix , vari , type , output ) { return new WOQLQuery ( ) . idgen ( prefix , vari , type , output ) ; }
52
52
WOQL . typecast = function ( vara , type , varb ) { return new WOQLQuery ( ) . typecast ( vara , type , varb ) ; }
53
53
54
+ WOQL . less = function ( v1 , v2 ) { return new WOQLQuery ( ) . less ( v1 , v2 ) ; }
55
+ WOQL . greater = function ( v1 , v2 ) { return new WOQLQuery ( ) . greater ( v1 , v2 ) ; }
56
+
54
57
55
58
/* Mathematical Processing */
56
59
WOQL . eval = function ( arith , v ) { return new WOQLQuery ( ) . eval ( arith , v ) ; }
@@ -286,6 +289,16 @@ WOQLQuery.prototype.join = function(...list){
286
289
return this ;
287
290
}
288
291
292
+ WOQLQuery . prototype . less = function ( v1 , v2 ) {
293
+ this . cursor [ 'less' ] = [ v1 , v2 ] ;
294
+ return this ;
295
+ }
296
+
297
+ WOQLQuery . prototype . greater = function ( v1 , v2 ) {
298
+ this . cursor [ 'greater' ] = [ v1 , v2 ] ;
299
+ return this ;
300
+ }
301
+
289
302
290
303
WOQLQuery . prototype . list = function ( ...vars ) {
291
304
this . cursor [ 'list' ] = vars ;
@@ -440,14 +453,22 @@ WOQLQuery.prototype.sub = function(a, b){
440
453
}
441
454
442
455
WOQLQuery . prototype . comment = function ( val ) {
443
- if ( val ) {
444
- val = ( val . json ? val . json ( ) : val )
445
- this . cursor [ 'comment' ] = val ;
456
+ if ( val && val . json ) {
457
+ this . cursor [ 'comment' ] = [ val . json ( ) ] ;
458
+ }
459
+ else if ( typeof val == "string" ) {
460
+ this . cursor [ 'comment' ] = [ { "@value" : val , "@language" : "en" } ] ;
461
+ }
462
+ else if ( typeof val == "object" ) {
463
+ if ( val . length ) this . cursor [ 'comment' ] = val ;
464
+ else this . cursor [ 'comment' ] = [ val ] ;
446
465
}
447
466
else {
448
- this . cursor [ 'comment' ] = null ;
449
- this . cursor = this . cursor [ 'comment' ] ;
467
+ this . cursor [ 'comment' ] = [ ] ;
450
468
}
469
+ var last_index = this . cursor [ 'comment' ] . length ;
470
+ this . cursor [ 'comment' ] [ last_index ] = { } ;
471
+ this . cursor = this . cursor [ 'comment' ] [ last_index ] ;
451
472
return this ;
452
473
}
453
474
@@ -684,7 +705,7 @@ WOQLQuery.prototype.label = function(l, lang){
684
705
}
685
706
686
707
WOQLQuery . prototype . description = function ( c , lang ) {
687
- if ( this . tripleBuilder ) this . tripleBuilder . comment ( c , lang ) ;
708
+ if ( this . tripleBuilder ) this . tripleBuilder . description ( c , lang ) ;
688
709
return this ;
689
710
}
690
711
@@ -1219,7 +1240,7 @@ WOQLQuery.prototype.getWOQLPrelude = function(operator, fluent, inline){
1219
1240
*/
1220
1241
WOQLQuery . prototype . chainable = function ( operator , lastArg ) {
1221
1242
const non_chaining_operators = [ "and" , "or" ] ;
1222
- if ( typeof lastArg == "object" && typeof lastArg [ '@value' ] == "undefined" && typeof lastArg [ '@type' ] == "undefined" && typeof lastArg [ 'value' ] == "undefined" && non_chaining_operators . indexOf ( operator ) == - 1 ) {
1243
+ if ( lastArg && typeof lastArg == "object" && typeof lastArg [ '@value' ] == "undefined" && typeof lastArg [ '@type' ] == "undefined" && typeof lastArg [ 'value' ] == "undefined" && non_chaining_operators . indexOf ( operator ) == - 1 ) {
1223
1244
return true ;
1224
1245
}
1225
1246
return false ;
@@ -1348,9 +1369,13 @@ WOQLQuery.prototype.uncleanObjectArgument = function(operator, val, index){
1348
1369
return JSON . stringify ( val ) ;
1349
1370
}
1350
1371
1351
- WOQLQuery . prototype . argIsSubQuery = function ( operator , args ) {
1352
- const squery_operators = [ "and" , "or" , "when" , "not" , "opt" ] ;
1353
- return ( squery_operators . indexOf ( operator ) !== - 1 ) ;
1372
+ WOQLQuery . prototype . argIsSubQuery = function ( operator , arg , index ) {
1373
+ const squery_operators = [ "and" , "or" , "when" , "not" , "opt" , "exp" , "minus" , "div" , "divide" , "plus" , "multiply" ] ;
1374
+ if ( squery_operators . indexOf ( operator ) !== - 1 ) {
1375
+ if ( arg && typeof arg != "object" ) return false ;
1376
+ return true ;
1377
+ }
1378
+ else return false ;
1354
1379
}
1355
1380
1356
1381
/**
@@ -1463,7 +1488,7 @@ TripleBuilder.prototype.label = function(l, lang){
1463
1488
return x ;
1464
1489
}
1465
1490
1466
- TripleBuilder . prototype . comment = function ( c , lang ) {
1491
+ TripleBuilder . prototype . description = function ( c , lang ) {
1467
1492
lang = ( lang ? lang : "en" ) ;
1468
1493
if ( c . substring ( 0 , 2 ) == "v:" ) {
1469
1494
var d = { "value" : l , "@language" : lang }
0 commit comments