(cherry picked from commit 189b7f9c0b)
Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
This commit is contained in:
co-authored by
kay delaney
parent
fb24f7de8c
commit
53a3dca76c
@@ -27,6 +27,8 @@ SELECT DISTINCT
|
||||
, (SELECT COUNT(connection_id) FROM ` + models.LibraryElementConnectionTableName + ` WHERE element_id = le.id AND kind=1) AS connected_dashboards`
|
||||
)
|
||||
|
||||
const deleteInvalidConnections = "DELETE FROM library_element_connection WHERE connection_id IN (SELECT connection_id as id FROM library_element_connection WHERE element_id=? EXCEPT SELECT id from dashboard)"
|
||||
|
||||
func getFromLibraryElementDTOWithMeta(dialect migrator.Dialect) string {
|
||||
user := dialect.Quote("user")
|
||||
userJoin := `
|
||||
@@ -179,6 +181,12 @@ func (l *LibraryElementService) deleteLibraryElement(c context.Context, signedIn
|
||||
if err := l.requirePermissionsOnFolder(c, signedInUser, element.FolderID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete any hanging/invalid connections
|
||||
if _, err = session.Exec(deleteInvalidConnections, element.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var connectionIDs []struct {
|
||||
ConnectionID int64 `xorm:"connection_id"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user