Skip to content

Commit

Permalink
Allow setting defaults from the outside and empty placeholders
Browse files Browse the repository at this point in the history
This allows changing the defaults in a way that sql-bricks works together with named parameters in pg-promise.
  • Loading branch information
kay999 authored Oct 31, 2016
1 parent b531d93 commit c884995
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 c884995

Please sign in to comment.