]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Support lightweight compiler column elements w/ slots
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 22 Nov 2021 15:59:06 +0000 (10:59 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 22 Nov 2021 16:26:33 +0000 (11:26 -0500)
commitd3a4e96196cd47858de072ae589c6554088edc24
tree7ef233ee6f106e1e70a1aed5166f09f4d5960196
parent0b95f0055be252b13e99b0a944466f60b5e367ff
Support lightweight compiler column elements w/ slots

the _CompileLabel class included ``__slots__`` but these
weren't used as the superclasses included slots.

Create a ``__slots__`` superclass for ``ClauseElement``,
creating a new class of compilable SQL elements that don't
include heavier features like caching, annotations and
cloning, which are meant to be used only in an ad-hoc
compiler fashion.   Create new ``CompilerColumnElement``
from that which serves in column-oriented contexts, but
similarly does not include any expression operator support
as it is intended to be used only to generate a string.

Apply this to both
``_CompileLabel`` as well as PostgreSQL ``_ColonCast``,
which does not actually subclass ``ColumnElement`` as this
class has memoized attributes that aren't worth changing,
and does not include SQL operator capabilities as these
are not needed for these compiler-only objects.

this allows us to more inexpensively add new ad-hoc
labels / casts etc. at compile time, as we will be seeking
to expand out the typecasts that are needed for PostgreSQL
dialects in a subsequent patch.

Change-Id: I52973ae3295cb6e2eb0d7adc816c678a626643ed
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/sql/annotation.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/roles.py
lib/sqlalchemy/sql/traversals.py
lib/sqlalchemy/sql/visitors.py
test/dialect/postgresql/test_compiler.py
test/sql/test_compiler.py