@@ -53,12 +53,14 @@ WOQL.typecast = function(vara, type, varb){ return new WOQLQuery().typecast(vara
53
53
54
54
55
55
/* Mathematical Processing */
56
- WOQL . eval = function ( arith , v ) { return new WOQLQuery ( ) . eval ( arith , v ) ; }
56
+ WOQL . eval = function ( arith , v ) { return new WOQLQuery ( ) . eval ( arith , v ) ; }
57
57
WOQL . plus = function ( ...args ) { return new WOQLQuery ( ) . plus ( ...args ) ; }
58
58
WOQL . minus = function ( ...args ) { return new WOQLQuery ( ) . minus ( ...args ) ; }
59
59
WOQL . times = function ( ...args ) { return new WOQLQuery ( ) . times ( ...args ) ; }
60
60
WOQL . divide = function ( ...args ) { return new WOQLQuery ( ) . divide ( ...args ) ; }
61
61
WOQL . exp = function ( a , b ) { return new WOQLQuery ( ) . exp ( a , b ) ; }
62
+ WOQL . div = function ( ...args ) { return new WOQLQuery ( ) . div ( ...args ) ; }
63
+ WOQL . comment = function ( arg ) { return new WOQLQuery ( ) . comment ( arg ) ; }
62
64
63
65
64
66
//language extensions that can be chained after 'grounded' stuff (clauses with a specific subject) sub, isa, delete_triple, add_triple, delete_quad, add_quad, node
@@ -437,6 +439,19 @@ WOQLQuery.prototype.sub = function(a, b){
437
439
return this . last ( "sub" , a ) ;
438
440
}
439
441
442
+ WOQLQuery . prototype . comment = function ( val ) {
443
+ if ( val ) {
444
+ val = ( val . json ? val . json ( ) : val )
445
+ this . cursor [ 'comment' ] = val ;
446
+ }
447
+ else {
448
+ this . cursor [ 'comment' ] = null ;
449
+ this . cursor = this . cursor [ 'comment' ] ;
450
+ }
451
+ return this ;
452
+ }
453
+
454
+
440
455
WOQLQuery . prototype . abstract = function ( varname ) {
441
456
if ( varname ) {
442
457
return this . quad ( varname , "tcs:tag" , "tcs:abstract" , "db:schema" ) ;
@@ -464,31 +479,54 @@ WOQLQuery.prototype.trim = function(a, b){
464
479
}
465
480
466
481
WOQLQuery . prototype . eval = function ( arith , v ) {
482
+ arith = arith . json ? arith . json ( ) : arith ;
467
483
this . cursor [ 'eval' ] = [ arith , v ] ;
468
484
return this . last ( 'eval' , v ) ;
469
485
}
470
486
471
487
WOQLQuery . prototype . plus = function ( ...args ) {
472
- this . cursor . plus = args ;
488
+ this . cursor . plus = [ ] ;
489
+ for ( var i = 0 ; i < args . length ; i ++ ) {
490
+ this . cursor . plus . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
491
+ }
473
492
return this . last ( ) ;
474
493
} ;
475
494
476
495
WOQLQuery . prototype . minus = function ( ...args ) {
477
- this . cursor . minus = args ;
496
+ this . cursor . minus = [ ] ;
497
+ for ( var i = 0 ; i < args . length ; i ++ ) {
498
+ this . cursor . minus . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
499
+ }
478
500
return this . last ( ) ;
479
501
} ;
480
502
481
503
WOQLQuery . prototype . times = function ( ...args ) {
482
- this . cursor . times = args ;
504
+ this . cursor . times = [ ] ;
505
+ for ( var i = 0 ; i < args . length ; i ++ ) {
506
+ this . cursor . times . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
507
+ }
483
508
return this . last ( ) ;
484
509
} ;
485
510
486
511
WOQLQuery . prototype . divide = function ( ...args ) {
487
- this . cursor . divide = args ;
512
+ this . cursor . divide = [ ] ;
513
+ for ( var i = 0 ; i < args . length ; i ++ ) {
514
+ this . cursor . divide . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
515
+ }
516
+ return this . last ( ) ;
517
+ } ;
518
+
519
+ WOQLQuery . prototype . div = function ( ...args ) {
520
+ this . cursor . div = [ ] ;
521
+ for ( var i = 0 ; i < args . length ; i ++ ) {
522
+ this . cursor . div . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
523
+ }
488
524
return this . last ( ) ;
489
525
} ;
490
526
491
527
WOQLQuery . prototype . exp = function ( a , b ) {
528
+ a = ( a . json ? a . json ( ) : a ) ;
529
+ b = ( b . json ? b . json ( ) : b ) ;
492
530
this . cursor . exp = [ a , b ] ;
493
531
return this . last ( ) ;
494
532
} ;
@@ -645,7 +683,7 @@ WOQLQuery.prototype.label = function(l, lang){
645
683
return this ;
646
684
}
647
685
648
- WOQLQuery . prototype . comment = function ( c , lang ) {
686
+ WOQLQuery . prototype . description = function ( c , lang ) {
649
687
if ( this . tripleBuilder ) this . tripleBuilder . comment ( c , lang ) ;
650
688
return this ;
651
689
}
@@ -1243,7 +1281,7 @@ WOQLQuery.prototype.uncleanArguments = function(operator, args, indent, show_con
1243
1281
*/
1244
1282
WOQLQuery . prototype . uncleanArgument = function ( operator , val , index , allArgs ) {
1245
1283
//numeric values go out untouched...
1246
- const numeric_operators = [ "limit" , "start" , "eval" , "plus" , "minus" , "times" , "divide" , "exp" ] ;
1284
+ const numeric_operators = [ "limit" , "start" , "eval" , "plus" , "minus" , "times" , "divide" , "exp" , "div" ] ;
1247
1285
if ( operator == "isa" ) {
1248
1286
val = ( index == 0 ? this . unclean ( val , 'subject' ) : this . unclean ( val , 'class' ) ) ;
1249
1287
}
0 commit comments