Skip to content

Commit 4d4f334

Browse files
add usePlaceholderId option
mysqljs (others might too) requires query values to be escaped [via a question mark](https://github.com/mysqljs/mysql#performing-queries). `usePlaceholderId` option is added In order to facilitate this behaviour ```javascript let jsonSql = require('json-sql')({ dialect: 'mysql', namedValues: false, valuesPrefix: '?', usePlaceholderId: false }); ```
1 parent 9f51372 commit 4d4f334

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/builder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Builder.prototype._reset = function() {
2727
};
2828

2929
Builder.prototype._getPlaceholder = function() {
30-
return (this.options.namedValues ? 'p' : '') + (this._placeholderId++);
30+
return (this.options.namedValues ? 'p' : '') + (this.options.usePlaceholderId ? (this._placeholderId++) : '');
3131
};
3232

3333
Builder.prototype._wrapPlaceholder = function(name) {
@@ -64,7 +64,8 @@ Builder.prototype.configure = function(options) {
6464
namedValues: true,
6565
valuesPrefix: '$',
6666
dialect: 'base',
67-
wrappedIdentifiers: true
67+
wrappedIdentifiers: true,
68+
usePlaceholderId: true
6869
});
6970

7071
this.setDialect(this.options.dialect);

0 commit comments

Comments
 (0)