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

43 lines
634 B
JavaScript
Raw Normal View History

/**
* Literal SQL string.
**/
Sql.String = new Class
({
Extends: Sql.Stmt
,Properties:
{
query:
{
type: String
,value: null
}
}
,regexp: /#\w+/g
,replaceFunc: function (batch, token)
{
var holder = new Sql.Holder ({id: token.substr (1)});
return holder.render (batch);
}
,render: function (batch)
{
if (!this.query)
return null;
return this.query.replace (this.regexp, this.replaceFunc.bind (this, batch));
}
,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;
}
});