Permalink
Browse files

Change helperOpts to function, fixing #80

  • Loading branch information...
1 parent 248d078 commit 2ab246b8e107b9e8223eeaac06b462af5a12eedd @dresende committed Nov 6, 2012
Showing with 19 additions and 15 deletions.
  1. +9 −7 lib/databases/mysql.js
  2. +10 −8 lib/databases/postgresql.js
@@ -222,7 +222,7 @@ DBClient.prototype._insertRecord = function (collection, data, cb) {
return helpers.createSqlInsert({
table: this._collectionToTable(collection),
escape: this._escapeId,
- info: helpers.escapeInsertFields(data, this._helperOpts),
+ info: helpers.escapeInsertFields(data, this._helperOpts()),
orm: this._orm,
data: data,
db: this._client,
@@ -235,21 +235,23 @@ DBClient.prototype._updateRecord = function (collection, propertyId, data, id, c
key: propertyId,
id: id,
escape: this._escapeId,
- info: helpers.escapeUpdateFields(data, this._escapeId, this._helperOpts),
+ info: helpers.escapeUpdateFields(data, this._escapeId, this._helperOpts()),
db: this._client,
callback: cb
});
};
DBClient.prototype._addQueryConditions = function (conditions) {
- return helpers.buildSqlWhere(conditions, this._escapeId, this._helperOpts);
+ return helpers.buildSqlWhere(conditions, this._escapeId, this._helperOpts());
};
DBClient.prototype._collectionToTable = function (collection) {
return collection.toLowerCase();
};
-DBClient.prototype._helperOpts = {
- date_convert_fmt: "FROM_UNIXTIME(?)",
- additional_operators: [ "LIKE", "ILIKE" ],
- boolean_convert: this._booleanToSqlValue
+DBClient.prototype._helperOpts = function () {
+ return {
+ date_convert_fmt: "FROM_UNIXTIME(?)",
+ additional_operators: [ "LIKE", "ILIKE" ],
+ boolean_convert: this._booleanToSqlValue
+ };
};
DBClient.prototype._booleanToSqlValue = function (value) {
return value ? 1 : 0;
@@ -251,7 +251,7 @@ DBClient.prototype._insertRecord = function (collection, propertyId, data, cb) {
return helpers.createSqlInsert({
table: this._collectionToTable(collection),
escape: this._escapeId,
- info: helpers.escapeInsertFields(data, this._helperOpts),
+ info: helpers.escapeInsertFields(data, this._helperOpts()),
orm: this._orm,
data: data,
db: this._client,
@@ -278,22 +278,24 @@ DBClient.prototype._updateRecord = function (collection, propertyId, data, id, c
key: propertyId,
id: id,
escape: this._escapeId,
- info: helpers.escapeUpdateFields(data, this._escapeId, this._helperOpts),
+ info: helpers.escapeUpdateFields(data, this._escapeId, this._helperOpts()),
db: this._client,
callback: cb
});
};
DBClient.prototype._addQueryConditions = function (conditions) {
- return helpers.buildSqlWhere(conditions, this._escapeId, this._helperOpts);
+ return helpers.buildSqlWhere(conditions, this._escapeId, this._helperOpts());
};
DBClient.prototype._collectionToTable = function (collection) {
return collection.toLowerCase();
};
-DBClient.prototype._helperOpts = {
- additional_operators: [ "LIKE", "ILIKE" ],
- date_convert_fmt: "TO_TIMESTAMP(?)::timestamp",
- boolean_convert: this._booleanToSqlValue,
- tokenCb: function (n) { return '$' + n; }
+DBClient.prototype._helperOpts = function () {
+ return {
+ additional_operators: [ "LIKE", "ILIKE" ],
+ date_convert_fmt: "TO_TIMESTAMP(?)::timestamp",
+ boolean_convert: this._booleanToSqlValue,
+ tokenCb: function (n) { return '$' + n; }
+ };
};
DBClient.prototype._booleanToSqlValue = function (value) {
return value ? 1 : 0;

0 comments on commit 2ab246b

Please sign in to comment.