You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactor rewrite_update() for cleaner bind parameter key representation #270
The rewrite_update() function in src/sqlalchemy_cratedb/compiler.py constructs bind parameter keys for partial ObjectType updates using the following format:
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:
# Beforenewparams["{0}['{1}']".format(key, subkey)] =subval# → data_'x'_ after sanitization# Afternewparams["{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.
The visit_update implementations in compat/coreXX.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.
Thank you so much for discovering this and coming up with a plan to resolve the flaw more sustainably!
Activity
amotl commentedon Jun 15, 2026
Thank you so much for discovering this and coming up with a plan to resolve the flaw more sustainably!
CompileError: Unconsumed column names#78