Merge pull request #925 from mnahkies/fix-prepare-value-map-to-postgres
Fix prepare value map to postgres
This commit is contained in:
commit
e6649f2650
@ -103,6 +103,10 @@ function normalizeQueryConfig (config, values, callback) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
prepareValue: prepareValue,
|
||||
prepareValue: function prepareValueWrapper (value) {
|
||||
//this ensures that extra arguments do not get passed into prepareValue
|
||||
//by accident, eg: from calling values.map(utils.prepareValue)
|
||||
return prepareValue(value);
|
||||
},
|
||||
normalizeQueryConfig: normalizeQueryConfig
|
||||
};
|
||||
|
@ -171,3 +171,14 @@ test('prepareValue: objects with circular toPostgres rejected', function() {
|
||||
}
|
||||
throw new Error("Expected prepareValue to throw exception");
|
||||
});
|
||||
|
||||
test('prepareValue: can safely be used to map an array of values including those with toPostgres functions', function() {
|
||||
var customType = {
|
||||
toPostgres: function() {
|
||||
return "zomgcustom!";
|
||||
}
|
||||
};
|
||||
var values = [1, "test", customType]
|
||||
var out = values.map(utils.prepareValue)
|
||||
assert.deepEqual(out, [1, "test", "zomgcustom!"])
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user