2do2go / json-sql

Node.js library for mapping mongo-style query objects to SQL queries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong parameter naming in builder.js

froehr opened this issue · comments

Builder.prototype._getPlaceholder = function () {
	var placeholder = '';
	if (this.options.namedValues) placeholder += 'p';
	if (this.options.indexedValues) placeholder += this._placeholderId++;
	return placeholder;
};

The code at the beginning creates the naming of parameters in prepared statements. Unfortunately it creates prameters with the pattern <valuesPrefix>p<numberOfParameter>. PostgreSQL is not accepting this naming pattern but only<valuesPrefix><numberOfParameter> without the p. You might want to fix that.

Builder instantiated with option namedValues: false will use proper pattern <valuesPrefix><numberOfParameter>. I think there nothing to fix.