keon94 commented on code in PR #5506:
URL: 
https://github.com/apache/incubator-devlake/pull/5506#discussion_r1232437484


##########
backend/helpers/pluginhelper/api/connection_helper.go:
##########
@@ -101,8 +104,16 @@ func (c *ConnectionApiHelper) List(connections 
interface{}) errors.Error {
 }
 
 // Delete connection
-func (c *ConnectionApiHelper) Delete(connection interface{}) errors.Error {
-       return CallDB(c.db.Delete, connection)
+func (c *ConnectionApiHelper) Delete(plugin string, connection interface{}) 
(*services.BlueprintProjectPairs, errors.Error) {
+       connectionId := reflectField(connection, "ID").Uint()
+       referencingBps, err := c.bpManager.GetBlueprintsByConnection(plugin, 
connectionId)
+       if err != nil {
+               return nil, err
+       }
+       if len(referencingBps) > 0 {
+               return services.NewBlueprintProjectPairs(referencingBps), 
errors.Conflict.New("Found one or more references to this connection")
+       }
+       return nil, CallDB(c.db.Delete, connection)

Review Comment:
   I agree the BE should behave in a self-contained way. But technically 
speaking, the whole lack of support for cascade-deletion that we initially 
decided on falls into this category, as well as the need for users to rerun 
their blueprints and manually fix DORA integrity problems. I think these have 
to be addressed with proper design and time in mind, and right now we're too 
tight on time to include in this release, so let's please settle for the 
simpler solution and have an issue/epic to capture the long term solution.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to