Skip to content

Commit

Permalink
Merge pull request #93 from kay999/patch-1
Browse files Browse the repository at this point in the history
Allow setting defaults from the outside and empty placeholders
  • Loading branch information
prust authored Oct 31, 2016
2 parents b531d93 + c884995 commit b996bee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sql-bricks.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
if (_.isArray(this.vals[0]))
this.vals = this.vals[0];
}
sql.setDefaultOpts = setDefaultOpts;
function setDefaultOpts(opts) {
default_opts = _.extend(default_opts, opts);
}
sql.prototype.toString = function toString(opts) {
// replacer(match, [capture1, capture2, ...,] offset, string)
function replacer() {
Expand Down Expand Up @@ -76,6 +80,7 @@
str = str.replace(/\$/g, replacer);
else if (opts.placeholder == '?')
str = str.replace(/\?/g, replacer);
else if (opts.placeholder == '') {}
else
throw new Error('Unsupported placeholder: "' + opts.placeholder + '"');
} else {
Expand Down

0 comments on commit b996bee

Please sign in to comment.