43 lines
634 B
JavaScript
43 lines
634 B
JavaScript
/**
|
|
* 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;
|
|
}
|
|
});
|