Refactor rewrite_update() for cleaner bind parameter key representation

Aperta
#270 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@bgunebakan ci sta già lavorando.

Dal 12/6/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Summary

The rewrite_update() function in src/sqlalchemy_cratedb/compiler.py constructs bind parameter keys for partial ObjectType updates using the following format:

newparams["{0}['{1}']".format(key, subkey)] = subval
# e.g., key="data", subkey="x" → "data['x']"

SQLAlchemy's IdentifierPreparer then sanitizes bind param names by replacing [ → _ and ] → _, but leaves the single quotes intact, resulting in keys like data_'x'_. This leaks internal bracket notation into the parameter dictionary, which is surprising for downstream consumers.

Proposed Change

Change how parameter keys are constructed in rewrite_update() to avoid embedding bracket notation:

# Before
newparams["{0}['{1}']".format(key, subkey)] = subval  # → data_'x'_ after sanitization

# After
newparams["{0}__{1}_".format(key, subkey)] = subval   # → data__x_ after sanitization

This would produce clean, quote-free bind parameter names that better reflect the column and sub-key relationship.

Related Context

  • The visit_update implementations in compat/core10.py, compat/core14.py, and compat/core20.py contain a deactivated SQLAlchemy sanity check ("Unconsumed column names") that was disabled precisely because of keys like data['nested'] not being recognised. Fixing the key format here may also allow re-enabling or simplifying that workaround.

References

Lingua principale
Python
Stelle
9
Fork
6
Merge medio
6g 13h
PR unite (30g)
8

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 crate/sqlalchemy-cratedb

Tutte le issue di crate/sqlalchemy-cratedb

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.