2016-09-26 09:28:47 +00:00
|
|
|
|
|
|
|
var Stmt = require ('./stmt');
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* The equivalent of a SQL multi statement.
|
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: Stmt
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,stmts: []
|
|
|
|
|
|
|
|
,addStmt: function (stmt)
|
|
|
|
{
|
|
|
|
return this.stmts.push (stmt);
|
|
|
|
}
|
|
|
|
|
2015-03-19 19:36:11 +00:00
|
|
|
,getStmt: function (stmtIndex)
|
|
|
|
{
|
|
|
|
return this.stmts[index];
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,isReady: function ()
|
|
|
|
{
|
|
|
|
if (this.stmts.length == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (var i = 0; i < this.stmts.length; i++)
|
|
|
|
if (!this.stmts[i].isReady ())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
,render: function (batch)
|
|
|
|
{
|
|
|
|
var sql = '';
|
|
|
|
|
|
|
|
for (var i = 0; i < this.stmts.length; i++)
|
2015-03-19 19:36:11 +00:00
|
|
|
{
|
|
|
|
if (i > 0)
|
|
|
|
sql += ";\n";
|
|
|
|
|
|
|
|
sql += this.stmts[i].render (batch);
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
return sql;
|
|
|
|
}
|
|
|
|
});
|