mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 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:
parent
a807d0c2c5
commit
d2c0c26252
1 changed files with 12 additions and 0 deletions
|
|
@ -1122,6 +1122,10 @@ func deleteByRootID(tx *sql.Tx, rootID string, context map[string]interface{}) (
|
||||||
if err = execStmtTx(tx, stmt, rootID); nil != err {
|
if err = execStmtTx(tx, stmt, rootID); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
stmt = "DELETE FROM attributes WHERE root_id = ?"
|
||||||
|
if err = execStmtTx(tx, stmt, rootID); nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
ClearCache()
|
ClearCache()
|
||||||
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, rootID)
|
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, rootID)
|
||||||
return
|
return
|
||||||
|
|
@ -1160,6 +1164,10 @@ func batchDeleteByRootIDs(tx *sql.Tx, rootIDs []string, context map[string]inter
|
||||||
if err = execStmtTx(tx, stmt); nil != err {
|
if err = execStmtTx(tx, stmt); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
stmt = "DELETE FROM attributes WHERE root_id IN " + ids
|
||||||
|
if err = execStmtTx(tx, stmt); nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
ClearCache()
|
ClearCache()
|
||||||
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, fmt.Sprintf("%d", len(rootIDs)))
|
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, fmt.Sprintf("%d", len(rootIDs)))
|
||||||
return
|
return
|
||||||
|
|
@ -1196,6 +1204,10 @@ func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
|
||||||
if err = execStmtTx(tx, stmt, boxID, pathPrefix+"%"); nil != err {
|
if err = execStmtTx(tx, stmt, boxID, pathPrefix+"%"); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
stmt = "DELETE FROM attributes WHERE box = ? AND path LIKE ?"
|
||||||
|
if err = execStmtTx(tx, stmt, boxID, pathPrefix+"%"); nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
ClearCache()
|
ClearCache()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue