From 1becdf8053972233fce234bd96ad9e16ac1bb230 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 18 Nov 2016 16:45:47 +0100 Subject: [PATCH 1/2] the ON CONFLICT feature for #PostgreSQL was missing camelcase support of column names this commit fixes that and takes care of issue #341 it now honours snakeToCamel set to true --- lib/dialect/postgres.js | 9 ++-- test/dialects/insert-tests.js | 83 +++++++++++++++++++++++++++++++++++ test/dialects/support.js | 9 ++++ 3 files changed, 97 insertions(+), 4 deletions(-) diff --git a/lib/dialect/postgres.js b/lib/dialect/postgres.js index a55f343d..bd125ae6 100644 --- a/lib/dialect/postgres.js +++ b/lib/dialect/postgres.js @@ -1041,13 +1041,13 @@ Postgres.prototype.visitOnDuplicate = function(onDuplicate) { Postgres.prototype.visitOnConflict = function(onConflict) { var result = ['ON CONFLICT']; var columns = []; - var updateClause = [], i; - + var updateClause = [], i, col; + var table = this._queryNode.table; if(onConflict.constraint) result.push(['ON CONSTRAINT', this.quote(onConflict.constraint)].join(' ')); else if(onConflict.columns) { for(i=0; i < onConflict.columns.length; i++) { - columns.push(this.quote(onConflict.columns[i])); + columns.push(this.quote(table.getColumn(onConflict.columns[i]).name)); } result.push( '(' + columns.join(', ') + ')' ); } @@ -1057,7 +1057,8 @@ Postgres.prototype.visitOnConflict = function(onConflict) { var update = onConflict.update; var setClause = []; for(i=0; i Date: Mon, 21 Nov 2016 11:06:26 +0100 Subject: [PATCH 2/2] we can quote the column name only once and save extra operation --- lib/dialect/postgres.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dialect/postgres.js b/lib/dialect/postgres.js index bd125ae6..9d9f547a 100644 --- a/lib/dialect/postgres.js +++ b/lib/dialect/postgres.js @@ -1057,8 +1057,8 @@ Postgres.prototype.visitOnConflict = function(onConflict) { var update = onConflict.update; var setClause = []; for(i=0; i