delete() does nothing when its restriction contains a percent sign
Maintainer thường phản hồi trong vòng 4 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Start with the cascade implementation around Diagram.cascade() and the restriction handling in restrict(), then trace how conditions are reapplied to the fresh table. Reproduce the % cases with the issue’s Label and Use example. Done means the cascade deletes the matching row and its descendants without changing behavior for ordinary conditions or LIKE patterns, with regression tests covering both database drivers.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
A delete restricted by a condition that contains % deletes nothing. (Label & "name = '50%'").delete() returns 0 and leaves the row and its descendants in place, and so does a dict restriction such as {"name": "50%"}. dj.Diagram.cascade(seed).counts() reports 0 rows for every table, although len(seed) is 1.
A restriction's conditions are stored as compiled SQL, with every % already escaped as %% for the database driver. The cascade applies the seed's conditions again to a fresh copy of the table through restrict(), which escapes every % a second time. The condition then looks for the literal text 50%% and matches no row.
A LIKE pattern keeps working, because %% and % match the same strings there.
Nothing is deleted that should not be, but the delete silently does nothing.
Reproduction
DataJoint 2.3.4 and master, MySQL 8.0 and PostgreSQL 15:
import datajoint as dj
schema = dj.Schema("scratch_percent")
@schema
class Label(dj.Manual):
definition = """
label_id : int32
---
name : varchar(16)
"""
@schema
class Use(dj.Manual):
definition = """
-> Label
use_id : int32
"""
Label.insert([(1, "50%"), (2, "other")])
Use.insert([(1, 1), (2, 1)])
seed = Label & "name = '50%'"
print(len(seed)) # 1
print(dj.Diagram.cascade(seed).counts()) # 0 rows in each table
print(seed.delete(prompt=False)) # 0; both labels and both uses remain
Workaround
Restrict by the primary keys: (Label & seed.keys()).delete().
Expected behavior
The cascade selects the same rows as the restriction on its own: label 1 and its use.
- Ngôn ngữ chính
- Python
- Star
- 197
- Fork
- 101
- Merge trung bình
- 3 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 28
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của datajoint/datajoint-python
-
len() of an expression with an empty primary key generates invalid SQLCó thể đã có người làm @dimitri-yatsenko đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
datajoint/datajoint-python#1581 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
dj.Diagram theme: make the font configurableCó thể đã có người làm @dimitri-yatsenko đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
datajoint/datajoint-python#1539 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
datajoint/datajoint-python#1644 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 68/100
datajoint/datajoint-python#1641 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schemaCó thể đã có người làm @dimitri-yatsenko đã nhận 5 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 82/100
datajoint/datajoint-python#1640 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của datajoint/datajoint-python
Issue tương tự
-
[oblt-aw][autodoc] Update workflow docs for gh-aw v0.92.5 and detector permission scopeCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feat(ide): VS Code access through the shipped MCP server (config doc and tool-list smoke test)Đang mởroadmap-100
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
comp/tools P2 tool/browser tool/file type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#143418 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
python-hyper/uritemplate#164 ·