From 54f424fed2eff08b6793fbe1eb2e86ac13197071 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Tue, 6 Oct 2020 17:19:55 +0200 Subject: [PATCH 1/4] Fix bug affecting sanitization version of sync tables --- app/models/synchronization/adapter.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/synchronization/adapter.rb b/app/models/synchronization/adapter.rb index 5ee4575da00e..9df6fc731b59 100644 --- a/app/models/synchronization/adapter.rb +++ b/app/models/synchronization/adapter.rb @@ -268,8 +268,7 @@ def import_cleanup(schema_name, table_name) # but is kept because there may be existing syncs for which this double sanitization # (version 1 sanitization which wasn't idemponent) had the effect of altering some # satinizated names (e.g. __1 -> _1). - table = ::Table.new(name: @table_name, user_id: @user.id) - # we could as well: table = Carto::UserTable.find(@user.tables.where(name: @table_name).first.id).service + table = Carto::UserTable.find(@user.tables.where(name: @table_name).first.id).service table.sanitize_columns(table_name: table_name, database_schema: schema_name, connection: user_database) # When tables are created using ogr2ogr they are added a ogc_fid or gid primary key From 1200543da34b9aa4aec153969f06f9bf4cb55f68 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Tue, 6 Oct 2020 17:32:10 +0200 Subject: [PATCH 2/4] Update NEWS --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index ad4edeb782fd..47b67931fb3d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ Development - None yet ### Features +* Fix column sanitization for connector syncs ([15885](https://github.com/CartoDB/cartodb/pull/15885)) * Load config files as ERB templates to allow reading ENV values ([15881](https://github.com/CartoDB/cartodb/pull/15881)) ### Bug fixes / enhancements From 6d1a8784bb310adf67936f78cd5f3c86a0672cde Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Tue, 6 Oct 2020 17:51:13 +0200 Subject: [PATCH 3/4] Choose a more idiomatic phrasing --- app/models/synchronization/adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/synchronization/adapter.rb b/app/models/synchronization/adapter.rb index 9df6fc731b59..ac33b70ec353 100644 --- a/app/models/synchronization/adapter.rb +++ b/app/models/synchronization/adapter.rb @@ -268,7 +268,7 @@ def import_cleanup(schema_name, table_name) # but is kept because there may be existing syncs for which this double sanitization # (version 1 sanitization which wasn't idemponent) had the effect of altering some # satinizated names (e.g. __1 -> _1). - table = Carto::UserTable.find(@user.tables.where(name: @table_name).first.id).service + table = Carto::UserTable.find(user.tables.find_by(name: 'upcase2').id).service table.sanitize_columns(table_name: table_name, database_schema: schema_name, connection: user_database) # When tables are created using ogr2ogr they are added a ogc_fid or gid primary key From 7775556418a3e8342343b543bf55ae85c2a71574 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 7 Oct 2020 09:48:06 +0200 Subject: [PATCH 4/4] Revert "Choose a more idiomatic phrasing" This reverts commit 6d1a8784bb310adf67936f78cd5f3c86a0672cde. The reason is that the change didn't work if user was a Sequel object (::User) rather than an ActiveRecord (Carto::User). --- app/models/synchronization/adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/synchronization/adapter.rb b/app/models/synchronization/adapter.rb index ac33b70ec353..9df6fc731b59 100644 --- a/app/models/synchronization/adapter.rb +++ b/app/models/synchronization/adapter.rb @@ -268,7 +268,7 @@ def import_cleanup(schema_name, table_name) # but is kept because there may be existing syncs for which this double sanitization # (version 1 sanitization which wasn't idemponent) had the effect of altering some # satinizated names (e.g. __1 -> _1). - table = Carto::UserTable.find(user.tables.find_by(name: 'upcase2').id).service + table = Carto::UserTable.find(@user.tables.where(name: @table_name).first.id).service table.sanitize_columns(table_name: table_name, database_schema: schema_name, connection: user_database) # When tables are created using ogr2ogr they are added a ogc_fid or gid primary key