var Expr = require ('./expr'); var ListHolder = require ('./list-holder'); /** * The equivalent of a SQL operation between exprs. * * @param {Array#Expr} exprs Array with the exprs * @param {Type} type The type of the operation */ var Klass = new Class (); module.exports = Klass; var Type = { EQUAL : 0 ,LIKE : 1 ,AND : 2 ,OR : 3 ,REGEXP : 4 }; var Operators = [ '=' ,'LIKE' ,'AND' ,'OR' ,'REGEXP' ]; Klass.extend ({ Type: Type ,Operators: Operators }); Klass.implement ({ Extends: Expr ,Implements: ListHolder ,Tag: 'sql-operation' ,Properties: { type: { enumType: Type ,value: -1 }, exprs: { type: Array ,set: function (x) { this.list = x; } ,get: function () { return this.list; } } } ,render: function (params) { var operator = ' '+ Operators[this.type] +' '; return '(' + this.renderListWs (this.list, params, operator) + ')'; } });