delete() does nothing when its restriction contains a percent sign
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 78/100
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Python
- 星號
- 197
- 分支
- 101
- 平均合併
- 2 天 10 小時
- 30 天內合併 PR
- 12
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
datajoint/datajoint-python 的其他 Issue
-
MySQL error 1143 (column-level SELECT denied) is not translated to AccessError可能已有人在做 @Bhanu73120 於 7 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 85/100
datajoint/datajoint-python#1586 · 1 則留言 ·
維護者通常 1 天內回覆
-
len() of an expression with an empty primary key generates invalid SQL可能已有人在做 @dimitri-yatsenko 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 70/100
datajoint/datajoint-python#1581 ·
維護者通常 1 天內回覆
-
dj.Diagram theme: make the font configurable可能已有人在做 @dimitri-yatsenko 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
datajoint/datajoint-python#1539 · 3 則留言 ·
維護者通常 1 天內回覆
-
enhancement
難度 4/5 3-5 天 新手友好度 55/100
datajoint/datajoint-python#1644 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 1-2 天 新手友好度 68/100
datajoint/datajoint-python#1641 ·
維護者通常 1 天內回覆
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
[Bug] Unit tests reach real Bedrock call paths without patching the model可能已有人在做 @proton0210 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 67/100
aws-samples/sample-aws-genai-db-modernizer#1318 · 1 則留言 ·
維護者通常 1 天內回覆
-
pyarrow-25.0.1-cp310-cp310-manylinux_2_28_x86_64.whl: 1 vulnerabilities (highest severity is: 5.3)未關閉Mend: dependency security vulnerability
難度 2/5 1-3 小時 新手友好度 62/100
capitalone/locopy#394 ·
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
sdk-typescript: unquoted COPY globs in shell form are silently dropped from the image build context未關閉bug javascript
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 65/100
ietf-tools/datatracker#11922 · 1 則留言 ·
維護者通常 1 天內回覆