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-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
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
query:
|
|
|
|
{
|
|
|
|
type: String
|
|
|
|
,value: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,regexp: /#\w+/g
|
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
,replaceFunc: function (params, token)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2016-09-26 09:28:47 +00:00
|
|
|
var holder = new Holder ({id: token.substr (1)});
|
2017-04-19 06:16:37 +00:00
|
|
|
return holder.render (params);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
,render: function (params)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
|
|
|
if (!this.query)
|
|
|
|
return null;
|
|
|
|
|
2017-04-19 06:16:37 +00:00
|
|
|
return this.query.replace (this.regexp, this.replaceFunc.bind (this, params));
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
});
|