AOSSIE-Org / AOSSIE-Org/PictoPy

BUG: Orphaned Rows in image_embeddings and semantic_labels on Image Deletion

オープン 初心者向け
#1,405 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
284
フォーク
680
平均マージ
7日 5時間
マージ済み PR(30日)
4

説明

### Is there an existing issue for this?

- [x] I have searched the existing issues

### What happened?

Files affected:

- `backend/app/database/image_embeddings.py`
- `backend/app/database/semantic_labels.py`

What is the problem?
Both database modules define foreign key constraints with `ON DELETE CASCADE` referencing the `images(id)` column. This is meant to ensure that when an image is deleted, its corresponding embeddings and semantic labels are deleted automatically.
However, both modules initialize database connections using `_connect()` from `app.database.images` which does not execute `PRAGMA foreign_keys = ON;`. Because SQLite disables foreign keys by default, deleting an image leaves **orphaned embeddings and semantic labels** in the database forever.

Proposed Fix:
Refactor both modules to use the `get_db_connection()` context manager from `app.database.connection` which enforces foreign key constraints correctly.

I wish to work on this issue!

### Record

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Read backend/app/database/image_embeddings.py and backend/app/database/semantic_labels.py, then inspect get_db_connection() in app.database.connection and the current _connect() usage from app.database.images. Replace the connection approach as described and verify that deleting an image also removes its embeddings and semantic labels without leaving orphaned rows.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python, sqlite
領域
database
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
78/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。