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

 ##########
 File path: superset/views/datasource.py
 ##########
 @@ -47,13 +51,29 @@ def save(self):
                 
.filter(orm_datasource.owner_class.id.in_(datasource["owners"]))
                 .all()
             )
+
+        duplicates = [
+            name
+            for name, count in Counter(
+                [col["column_name"] for col in datasource["columns"]]
+            ).items()
+            if count > 1
+        ]
+        if duplicates:
+            return json_error_response(
+                f"Duplicate column name(s): {','.join(duplicates)}", 
status="500"
 
 Review comment:
   Consider using 409 or 422 instead of 500

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


With regards,
Apache Git Services

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

Reply via email to