AOSSIE-Org / AOSSIE-Org/PictoPy

BUG: Database Integrity Issues - Foreign Key Constraints Not Enforced

未關閉
#571 3 則留言 0 個 reaction 已指派 1 人 已被 @Hemil36 認領 在 GitHub 檢視
backend bug
主要語言
Python
星號
283
分支
679
平均合併
7 天 2 小時
30 天內合併 PR
3

描述

### Is there an existing issue for this?

- [x] I have searched the existing issues

### What happened?

**Description**

SQLite disables foreign key constraints **by default**, meaning all foreign key rules (such as `ON DELETE CASCADE` and `ON DELETE SET NULL`) are ignored unless explicitly enabled.

Several database functions directly call:

```python
conn = sqlite3.connect(DATABASE_PATH)
```

without running:

```sql
PRAGMA foreign_keys = ON;
```

As a result, foreign key relationships are **silently ignored**, and the database accepts invalid references.

If the foreign key enforcement remains disabled:

* **Data integrity** will continue degrading silently.
* **Cascading deletes** and **SET NULL behaviors** will never trigger.
* The database will accumulate **orphaned and invalid records**.
* **JOIN queries** and **application logic** relying on relationships will fail or produce incorrect results.
* Over time, the application data becomes **irrecoverably inconsistent**, potentially requiring full data cleanup or migration.

### Record

- [x] I agree to follow this project's Code of Conduct

### Checklist before Submitting

- [ ] Have you updated docs for it?
- [ ] Have you added unit tests?
- [ ] Have you made sure unit tests pass?
- [x] Have you made sure code formatting is correct?
- [ ] Do Your changes passes all tests?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。