Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

delete() does nothing when its restriction contains a percent sign

Aperta
#1,636 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
mysql, postgresql, python
Ambito
database

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

bug

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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di datajoint/datajoint-python

Tutte le issue di datajoint/datajoint-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.