48 lines
733 B
JavaScript
48 lines
733 B
JavaScript
/**
|
|
* The equivalent of a SQL operation.
|
|
**/
|
|
Sql.Filter = new Class
|
|
({
|
|
Extends: Sql.Operation
|
|
,Tag: 'sql-filter'
|
|
,Properties:
|
|
{
|
|
alwaysReady:
|
|
{
|
|
type: Boolean
|
|
}
|
|
}
|
|
|
|
,isReady: function ()
|
|
{
|
|
if (this.alwaysReady)
|
|
return true;
|
|
|
|
var e = this.exprs.getArray ();
|
|
for (var i = 0; i < e.length; i++)
|
|
if (e[i].isReady () && e[i].primary)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
,render: function (batch)
|
|
{
|
|
var isReady = false;
|
|
var newOp = new Sql.Operation ({type: this.type});
|
|
|
|
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);
|
|
}
|
|
});
|