delete() does nothing when its restriction contains a percent sign
Los mantenedores suelen responder en 4 días
@dimitri-yatsenko ya está trabajando en esto.
Desde el 17/10/2026.
- #1611 de @dimitri-yatsenko — abierto
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 78/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 197
- Forks
- 101
- Merge medio
- 3 d 8 h
- PR fusionados (30 d)
- 28
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de datajoint/datajoint-python
-
len() of an expression with an empty primary key generates invalid SQLPosiblemente ocupada @dimitri-yatsenko la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
datajoint/datajoint-python#1581 ·
Los mantenedores suelen responder en 4 días
-
dj.Diagram theme: make the font configurablePosiblemente ocupada @dimitri-yatsenko la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
datajoint/datajoint-python#1539 · 3 comentarios ·
Los mantenedores suelen responder en 4 días
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
datajoint/datajoint-python#1644 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
bug
Dificultad 4/5 1-2 días Aptitud para principiantes 68/100
datajoint/datajoint-python#1641 ·
Los mantenedores suelen responder en 4 días
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schemaPosiblemente ocupada @dimitri-yatsenko la tomó hace 4 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 82/100
datajoint/datajoint-python#1640 · 1 comentario ·
Los mantenedores suelen responder en 4 días
Todos los issues de datajoint/datajoint-python
Issues similares
-
comp/tools P2 type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#142908 · 1 comentario ·
-
[oblt-aw][autodoc] Fix malformed headings in new Buildkite docs pagesPosiblemente ocupada @github-actions la tomó hoy. Abiertodocumentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offlinePosiblemente ocupada @r2jaff la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ComposioHQ/composio#5054 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
pytorch/tensordict#3286 ·
Los mantenedores suelen responder en 1 día