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 /test/sql/test_selectable.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 'test/sql/test_selectable.py')
| -rw-r--r-- | test/sql/test_selectable.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 04c0e6102..a4d3e1b40 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -28,6 +28,7 @@ from sqlalchemy import type_coerce from sqlalchemy import TypeDecorator from sqlalchemy import union from sqlalchemy import util +from sqlalchemy.sql import Alias from sqlalchemy.sql import column from sqlalchemy.sql import elements from sqlalchemy.sql import expression @@ -871,6 +872,18 @@ class SelectableTest( Table("t1", MetaData(), c1) eq_(c1._label, "t1_c1") + def test_no_alias_construct(self): + a = table("a", column("x")) + + assert_raises_message( + NotImplementedError, + "The Alias class is not intended to be constructed directly. " + r"Please use the alias\(\) standalone function", + Alias, + a, + "foo", + ) + class RefreshForNewColTest(fixtures.TestBase): def test_join_uninit(self): |
