Skip to content

Commit

Permalink
fix: escapeObject parameter order for Postgres dialect. (#2003)
Browse files Browse the repository at this point in the history
* fix: escapeObject parameter order for Postgres dialect.

* test: escapeObject for Postgres dialect.
  • Loading branch information
santegoeds authored and elhigu committed Apr 12, 2017
1 parent a5f4c39 commit 5c0b193
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dialects/postgres/index.js
Expand Up @@ -78,7 +78,7 @@ assign(Client_PG.prototype, {
}
return escaped
},
escapeObject(val, timezone, prepareValue, seen = []) {
escapeObject(val, prepareValue, timezone, seen = []) {
if (val && typeof val.toPostgres === 'function') {
seen = seen || [];
if (seen.indexOf(val) !== -1) {
Expand Down
9 changes: 9 additions & 0 deletions test/unit/query/builder.js
Expand Up @@ -4182,4 +4182,13 @@ describe("QueryBuilder", function() {
});
})

it('#2003, properly escapes objects with toPostgres specialization', function () {
function TestObject() { }
TestObject.prototype.toPostgres = function() {
return 'foobar'
}
testquery(qb().table('sometable').insert({ id: new TestObject() }), {
postgres: "insert into \"sometable\" (\"id\") values ('foobar')"
});
})
});

0 comments on commit 5c0b193

Please sign in to comment.