2016-09-26 09:28:47 +00:00
|
|
|
|
|
|
|
var Stmt = require ('./stmt');
|
|
|
|
var Holder = require ('./holder');
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* Literal SQL string.
|
|
|
|
**/
|
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
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
query:
|
|
|
|
{
|
|
|
|
type: String
|
|
|
|
,value: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,regexp: /#\w+/g
|
|
|
|
|
|
|
|
,replaceFunc: function (batch, token)
|
|
|
|
{
|
2016-09-26 09:28:47 +00:00
|
|
|
var holder = new Holder ({id: token.substr (1)});
|
2015-01-23 13:09:30 +00:00
|
|
|
return holder.render (batch);
|
|
|
|
}
|
|
|
|
|
|
|
|
,render: function (batch)
|
|
|
|
{
|
|
|
|
if (!this.query)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return this.query.replace (this.regexp, this.replaceFunc.bind (this, batch));
|
|
|
|
}
|
|
|
|
|
2016-01-07 12:58:29 +00:00
|
|
|
,findHolders: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
|
|
|
var ids = this.query.match (this.regexp);
|
|
|
|
|
|
|
|
if (ids)
|
|
|
|
for (var i = 0; i < ids.length; i++)
|
2016-01-07 12:58:29 +00:00
|
|
|
ids[i] = ids[i].substr (1);
|
|
|
|
|
|
|
|
return ids;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|