You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/12/03 01:20:49 UTC

[GitHub] [incubator-superset] john-bodley commented on a change in pull request #8712: catch IntegrityError in datasource save

john-bodley commented on a change in pull request #8712: catch IntegrityError in datasource save
URL: https://github.com/apache/incubator-superset/pull/8712#discussion_r352943290
 
 

 ##########
 File path: superset/views/datasource.py
 ##########
 @@ -47,13 +50,24 @@ def save(self):
                 .filter(orm_datasource.owner_class.id.in_(datasource["owners"]))
                 .all()
             )
+
+        column_names = [o["column_name"] for o in datasource["columns"]]
 
 Review comment:
   I think this could be simplified to (which is more efficient for counting), 
   
   ```
   from collections import Counter
   
   duplicates = [
       name
       for name, count in Counter(
           [col["column_name"] for col in datasource["columns"]]
       ).items()
       if count > 1
   ]
   
   if duplicates:
       ...
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org