forked from verdnatura/hedera-web
41 lines
624 B
JavaScript
Executable File
41 lines
624 B
JavaScript
Executable File
/**
|
|
* 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 (batch)
|
|
{
|
|
var ids = this.query.match (this.regexp);
|
|
|
|
if (ids)
|
|
for (var i = 0; i < ids.length; i++)
|
|
batch.add (ids[i].substr (1));
|
|
}
|
|
});
|