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
Simplify: fix templates on the class via property descriptors
The previous revision had two method overrides — bindparam_string for
the compile-time path and _literal_execute_expanding_parameter for the
IN-expansion path — with the latter doing a try/finally state swap of
the template attributes. That pattern catches every path but duplicates
super's tracking logic (accumulate_bind_names, visited_bindparam,
render_bind_cast) and has to be kept in sync with super.
Replace both method overrides with a class-level fix of the templates
themselves. Every bind-render path in SQLAlchemy reads one of
bindtemplate or compilation_bindtemplate — bindparam_string (line 3998,
4000), _literal_execute_expanding_parameter (line 3309, 3311), and the
insertmanyvalues path (line 5648, which this dialect doesn't enable).
Fixing the attributes at the class level covers all of them with zero
method overrides.
Use property descriptors with no-op setters because
SQLCompiler.__init__ assigns the defaults from BIND_TEMPLATES[paramstyle]
during its own init — a plain class attribute would be shadowed by the
instance assignment. The no-op setter silently discards super's
assignment so our class-level value is always what gets read.
Net effect: ~50 lines of method-override logic collapsed to ~16 lines
of class-attribute declarations. Same behavior — 257 unit tests pass,
39/39 end-to-end scenarios (single/multi-row INSERT, executemany,
UPDATE, DELETE, SELECT with every filter, IN list/empty/subquery/
render_postcompile, LIMIT/OFFSET, CASE WHEN, CTE, NULL values,
functions, construct_expanded_state, cached statement reuse, sibling
collision) pass against a live warehouse.
Co-authored-by: Isaac
0 commit comments