0
1
Fork 0
hedera-web-mindshore/js/sql/string.js

47 lines
701 B
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
var Stmt = require ('./stmt');
var Holder = require ('./holder');
/**
* Literal SQL string.
2016-12-20 09:32:17 +00:00
*/
2016-09-26 09:28:47 +00:00
module.exports = new Class
({
2016-09-26 09:28:47 +00:00
Extends: Stmt
,Properties:
{
query:
{
type: String
,value: null
}
}
,regexp: /#\w+/g
2017-04-19 06:16:37 +00:00
,replaceFunc: function (params, token)
{
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);
}
2017-04-19 06:16:37 +00:00
,render: function (params)
{
if (!this.query)
return null;
2017-04-19 06:16:37 +00:00
return this.query.replace (this.regexp, this.replaceFunc.bind (this, params));
}
,findHolders: function ()
{
var ids = this.query.match (this.regexp);
if (ids)
for (var i = 0; i < ids.length; i++)
ids[i] = ids[i].substr (1);
return ids;
}
});