🎨 Delete the corresponding data in the database attributes table after deleting the doc https://github.com/siyuan-note/siyuan/issues/9875

This commit is contained in:
Daniel 2023-12-15 08:56:44 +08:00
parent a807d0c2c5
commit d2c0c26252
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1122,6 +1122,10 @@ func deleteByRootID(tx *sql.Tx, rootID string, context map[string]interface{}) (
if err = execStmtTx(tx, stmt, rootID); nil != err {
return
}
stmt = "DELETE FROM attributes WHERE root_id = ?"
if err = execStmtTx(tx, stmt, rootID); nil != err {
return
}
ClearCache()
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, rootID)
return
@ -1160,6 +1164,10 @@ func batchDeleteByRootIDs(tx *sql.Tx, rootIDs []string, context map[string]inter
if err = execStmtTx(tx, stmt); nil != err {
return
}
stmt = "DELETE FROM attributes WHERE root_id IN " + ids
if err = execStmtTx(tx, stmt); nil != err {
return
}
ClearCache()
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, fmt.Sprintf("%d", len(rootIDs)))
return
@ -1196,6 +1204,10 @@ func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
if err = execStmtTx(tx, stmt, boxID, pathPrefix+"%"); nil != err {
return
}
stmt = "DELETE FROM attributes WHERE box = ? AND path LIKE ?"
if err = execStmtTx(tx, stmt, boxID, pathPrefix+"%"); nil != err {
return
}
ClearCache()
return
}