delete() does nothing when its restriction contains a percent sign
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 78/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 197
- Fork
- 101
- Merge medio
- 2g 10h
- PR unite (30g)
- 12
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di datajoint/datajoint-python
-
MySQL error 1143 (column-level SELECT denied) is not translated to AccessErrorForse già presa @Bhanu73120 l’ha presa 7 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
datajoint/datajoint-python#1586 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
len() of an expression with an empty primary key generates invalid SQLForse già presa @dimitri-yatsenko l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
datajoint/datajoint-python#1581 ·
I maintainer di solito rispondono entro 1 giorno
-
dj.Diagram theme: make the font configurableForse già presa @dimitri-yatsenko l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
datajoint/datajoint-python#1539 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
datajoint/datajoint-python#1644 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 1-2 giorni Idoneità per principianti 68/100
datajoint/datajoint-python#1641 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di datajoint/datajoint-python
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
anchore/grype-db#1149 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sitesForse già presa @HootRock l’ha presa oggi. Apertacomp/cli P2 type/perf
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NousResearch/hermes-agent#142417 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
SMC SPEC
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
tenstorrent/tt-oca-harness#3287 ·
I maintainer di solito rispondono entro 1 giorno
-
bug enhancement python
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
I maintainer di solito rispondono entro 1 giorno
-
Critical advisories on mainApertasecurity
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
fabriziosalmi/wildbox#801 ·
I maintainer di solito rispondono entro 1 giorno