diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-02-20 15:00:09 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-02-21 11:18:19 -0500 |
commit | 4ca3092c0a89855cd740bafb4e0fb4c99051f89e (patch) | |
tree | e8a42e8391cf1b30f5b20ba10da1f3fa9f97e17c /lib/sqlalchemy/sql/expression.py | |
parent | 7a4c40ff6b9d278529735c792c3ddfda60bd4a85 (diff) | |
download | sqlalchemy-4ca3092c0a89855cd740bafb4e0fb4c99051f89e.tar.gz |
Prevent __init__ from being called for Alias, subclasses
The :class:`.Alias` class and related subclasses :class:`.CTE`,
:class:`.Lateral` and :class:`.TableSample` have been reworked so that it is
not possible for a user to construct the objects directly. These constructs
require that the standalone construction function or selectable-bound method
be used to instantiate new objects.
Fixes: #4509
Change-Id: I74ae4786cb3ae625dab33b00bfd6bdc4e1219139
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 82fe93029..f381879ce 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -39,6 +39,7 @@ __all__ = [ "case", "cast", "column", + "cte", "delete", "desc", "distinct", @@ -148,7 +149,6 @@ from .functions import FunctionElement # noqa from .functions import modifier # noqa from .selectable import _interpret_as_from # noqa from .selectable import Alias # noqa -from .selectable import alias # noqa from .selectable import CompoundSelect # noqa from .selectable import CTE # noqa from .selectable import Exists # noqa @@ -160,7 +160,6 @@ from .selectable import HasPrefixes # noqa from .selectable import HasSuffixes # noqa from .selectable import Join # noqa from .selectable import Lateral # noqa -from .selectable import lateral # noqa from .selectable import ScalarSelect # noqa from .selectable import Select # noqa from .selectable import Selectable # noqa @@ -168,7 +167,6 @@ from .selectable import SelectBase # noqa from .selectable import subquery # noqa from .selectable import TableClause # noqa from .selectable import TableSample # noqa -from .selectable import tablesample # noqa from .selectable import TextAsFrom # noqa from .visitors import Visitable # noqa from ..util.langhelpers import public_factory # noqa @@ -182,6 +180,9 @@ from ..util.langhelpers import public_factory # noqa all_ = public_factory(CollectionAggregate._create_all, ".expression.all_") any_ = public_factory(CollectionAggregate._create_any, ".expression.any_") and_ = public_factory(BooleanClauseList.and_, ".expression.and_") +alias = public_factory(Alias._factory, ".expression.alias") +tablesample = public_factory(TableSample._factory, ".expression.tablesample") +lateral = public_factory(Lateral._factory, ".expression.lateral") or_ = public_factory(BooleanClauseList.or_, ".expression.or_") bindparam = public_factory(BindParameter, ".expression.bindparam") select = public_factory(Select, ".expression.select") @@ -193,6 +194,7 @@ within_group = public_factory(WithinGroup, ".expression.within_group") label = public_factory(Label, ".expression.label") case = public_factory(Case, ".expression.case") cast = public_factory(Cast, ".expression.cast") +cte = public_factory(CTE._factory, ".expression.cte") extract = public_factory(Extract, ".exp # noqaression.extract") tuple_ = public_factory(Tuple, ".expression.tuple_") except_ = public_factory(CompoundSelect._create_except, ".expression.except_") |