john-bodley commented on a change in pull request #5449: [schema] Updating the 
tables schema
URL: 
https://github.com/apache/incubator-superset/pull/5449#discussion_r332617706
 
 

 ##########
 File path: superset/connectors/sqla/views.py
 ##########
 @@ -348,14 +353,7 @@ class TableModelView(DatasourceModelView, DeleteMixin, 
YamlExportMixin):  # noqa
     }
 
     def pre_add(self, table):
-        with db.session.no_autoflush:
-            table_query = db.session.query(models.SqlaTable).filter(
-                models.SqlaTable.table_name == table.table_name,
-                models.SqlaTable.schema == table.schema,
-                models.SqlaTable.database_id == table.database.id,
-            )
-            if db.session.query(table_query.exists()).scalar():
-                raise 
Exception(get_datasource_exist_error_msg(table.full_name))
+        models.SqlaTable.before_insert(None, None, table)
 
 Review comment:
   @dpgaspar yes this still seems to be an issues, i.e., when trying to re-add 
the `birth_names` table,
   
   **Without before_insert(...)**
   
   ![Screen Shot 2019-10-08 at 9 40 04 
AM](https://user-images.githubusercontent.com/4567245/66415168-d5fa2580-e9af-11e9-9b91-41a2f26b12f1.png)
   
   **With before_insert(...)**
   
   ![Screen Shot 2019-10-08 at 9 40 27 
AM](https://user-images.githubusercontent.com/4567245/66415176-dabed980-e9af-11e9-9d3a-11eabb6e90f7.png)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to