File tree Expand file tree Collapse file tree
TablePro/Core/ChangeTracking Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -682,10 +682,12 @@ final class DataChangeManager {
682682 )
683683 }
684684
685- let expectedDeletes = changes. count ( where: { $0. type == . delete && deletedRowIndices. contains ( $0. rowIndex) } )
686- let actualDeletes = statements. count ( where: { $0. sql. hasPrefix ( " DELETE " ) } )
685+ // Validate DELETE coverage: batch DELETE produces 1 statement for N rows when PK exists,
686+ // so count statements != count rows. Instead check that all deletable rows got coverage.
687+ let deletableChanges = changes. filter { $0. type == . delete && deletedRowIndices. contains ( $0. rowIndex) }
688+ let deletableWithOriginalRow = deletableChanges. filter { $0. originalRow != nil }
687689
688- if expectedDeletes > 0 && actualDeletes < expectedDeletes {
690+ if !deletableChanges . isEmpty && deletableWithOriginalRow . isEmpty {
689691 throw DatabaseError . queryFailed (
690692 " Cannot save DELETE changes to table ' \( tableName) '. " +
691693 " Some rows could not be identified for deletion. Please verify the table data. "
You can’t perform that action at this time.
0 commit comments