Represents a complex SQL expression, with a given operator and one or more attributes (which may also be ComplexExpressions, forming a tree).

This is an abstract class that is not that useful by itself. The subclasses @link patio.sql.BooleanExpression}, patio.sql.NumericExpression and patio.sql.StringExpression should be used instead of this class directly.

Extends Static Properties
PropertyTypeDefault ValueDescription
BITWISE_OPERATORSObject {bitWiseAnd:"&", bitWiseOr:"|", exclusiveOr:"^", leftShift:"<<", rightShift:">>"}

Default bitwise operators.

BOOLEAN_OPERATORSObject {AND:"AND",OR:"OR"}

Default boolean operators.

INEQUALITY_OPERATORSObject {GT:">",GTE:">=",LT:"<",LTE:"<="}

Default inequality operators.

IN_OPERATORSObject {IN:"IN",NOTIN:'NOT IN'}

Default IN operators.

IS_OPERATORSObject {IS:"IS", ISNOT:'IS NOT'}

Default IS operators.

MATHEMATICAL_OPERATORSObject {PLUS:"+", MINUS:"-", DIVIDE:"/", MULTIPLY:"*"}

Default mathematical operators.

N_ARITY_OPERATORSObject { "||":"||", AND:"AND", OR:"OR", PLUS:"+", MINUS:"-", DIVIDE:"/", MULTIPLY:"*" }

Default N(multi) arity operators.

ONE_ARITY_OPERATORSObject { "NOT":"NOT", "NOOP":"NOOP" }

Default ONE operators.

OPERATOR_INVERSIONSObject { AND:"OR", OR:"AND", GT:"lte", GTE:"lt", LT:"gte", LTE:"gt", EQ:"neq", NEQ:"eq", LIKE:'NOT LIKE', "NOT LIKE":"LIKE", '!~*':'~*', '~*':'!~*', "~":'!~', "IN":'NOTIN', "NOTIN":"IN", "IS":'IS NOT', "ISNOT":"IS", NOT:"NOOP", NOOP:"NOT", ILIKE:'NOT ILIKE', NOTILIKE:"ILIKE" }

Hash of operator inversions

TWO_ARITY_OPERATORSObject { EQ:'=', NEQ:'!=', LIKE:"LIKE", "NOT LIKE":'NOT LIKE', ILIKE:"ILIKE", "NOT ILIKE":'NOT ILIKE', "~":"~", '!~':"!~", '~*':"~*", '!~*':"!~*", GT:">", GTE:">=", LT:"<", LTE:"<=", bitWiseAnd:"&", bitWiseOr:"|", exclusiveOr:"^", leftShift:"<<", rightShift:">>", IS:"IS", ISNOT:'IS NOT', IN:"IN", NOTIN:'NOT IN' }

Default two arity operators.

Constructor

Defined sql.js Throws Source
function (op){
   if (op) {
       var args = argsToArray(arguments, 1);
       //make a copy of the args
       var origArgs = args.slice(0);
       args.forEach(function (a, i) {
           if (Expression.isConditionSpecifier(a)) {
               args[i] = BooleanExpression.fromValuePairs(a);
           }
       });
       op = op.toUpperCase();
       if (N_ARITY_OPERATORS.hasOwnProperty(op)) {
           if (args.length &lt; 1) {
               throw new ExpressionError("The " + op + " operator requires at least 1 argument");
           }
           var oldArgs = args.slice(0);
           args = [];
           oldArgs.forEach(function (a) {
               a instanceof ComplexExpression && a.op === op ? args = args.concat(a.args) : args.push(a);
           });
       } else if (TWO_ARITY_OPERATORS.hasOwnProperty(op)) {
           if (args.length !== 2) {
               throw new ExpressionError("The " + op + " operator requires precisely 2 arguments");
           }
           //With IN/NOT IN, even if the second argument is an array of two element arrays,
           //don't convert it into a boolean expression, since it's definitely being used
           //as a value list.
           if (IN_OPERATORS[op]) {
               args[1] = origArgs[1];
           }
       } else if (ONE_ARITY_OPERATORS.hasOwnProperty(op)) {
           if (args.length !== 1) {
               throw new ExpressionError("The " + op + " operator requires only one argument");
           }
       } else {
           throw new ExpressionError("Invalid operator " + op);
       }
       this.op = op;
       this.args = args;
   }
           
}
            

toString Function Public


Defined sql.js

Converts the ComplexExpression to a string.

Arguments Returns Source
function (ds){
   !Dataset && (Dataset = require("./dataset"));
   ds = ds || new Dataset();
   return ds.complexExpressionSql(this.op, this.args);
           
}
    

Documentation generated using coddoc.