2016-09-26 09:28:47 +00:00
|
|
|
|
|
|
|
var Operation = require ('./operation');
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* The equivalent of a SQL operation.
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Operation
|
2015-01-23 13:09:30 +00:00
|
|
|
,Tag: 'sql-filter'
|
2015-11-17 10:34:33 +00:00
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
alwaysReady:
|
|
|
|
{
|
|
|
|
type: Boolean
|
|
|
|
}
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,isReady: function ()
|
|
|
|
{
|
2015-11-17 10:34:33 +00:00
|
|
|
if (this.alwaysReady)
|
|
|
|
return true;
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
var e = this.exprs.getArray ();
|
2015-01-23 13:09:30 +00:00
|
|
|
for (var i = 0; i < e.length; i++)
|
2015-11-19 13:57:23 +00:00
|
|
|
if (e[i].isReady () && e[i].primary)
|
2015-01-23 13:09:30 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-17 10:34:33 +00:00
|
|
|
|
|
|
|
,render: function (batch)
|
|
|
|
{
|
|
|
|
var isReady = false;
|
2016-09-26 09:28:47 +00:00
|
|
|
var newOp = new Operation ({type: this.type});
|
2015-11-17 10:34:33 +00:00
|
|
|
|
|
|
|
var e = this.exprs.getArray ();
|
|
|
|
for (var i = 0; i < e.length; i++)
|
|
|
|
if (e[i].isReady ())
|
|
|
|
{
|
|
|
|
newOp.exprs.add (e[i]);
|
|
|
|
isReady = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isReady)
|
|
|
|
return 'TRUE';
|
|
|
|
|
|
|
|
return newOp.render (batch);
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|