summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-12-03 19:50:01 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-12-03 19:50:01 -0500
commit699146086df8fd8778582a03267f8f28c5cdad7a (patch)
tree80118f3c361508f0aab5f10995f96870bdc8cc5d /test/sql/test_selectable.py
parentd628967ad21ab103f3c2766728a5b18923348795 (diff)
downloadsqlalchemy-699146086df8fd8778582a03267f8f28c5cdad7a.tar.gz
- [bug] Fixed bug whereby column_property() created
against ORM-level column could be treated as a distinct entity when producing certain kinds of joined-inh joins. [ticket:2316] - [bug] related to [ticket:2316], made some adjustments to the change from [ticket:2261] regarding the "from" list on a select(). The _froms collection is no longer memoized, as this simplifies various use cases and removes the need for a "warning" if a column is attached to a table after it was already used in an expression - the select() construct will now always produce the correct expression. There's probably no real-world performance hit here; select() objects are almost always made ad-hoc, and systems that wish to optimize the re-use of a select() would be using the "compiled_cache" feature. A hit which would occur when calling select.bind has been reduced, but the vast majority of users shouldn't be using "bound metadata" anyway :).
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r--test/sql/test_selectable.py37
1 files changed, 17 insertions, 20 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index e9596b1ae..a4c3ddf40 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -437,13 +437,11 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
s2 = select([c2])
s3 = sql_util.ClauseAdapter(s).traverse(s2)
- # the adaptation process needs the full
- # FROM list so can't avoid the warning on
- # this one
- assert_raises_message(
- exc.SAWarning,
- r"\<class 'sqlalchemy.schema.Table'\> being associated ",
- Table, 't', MetaData(), c1
+ Table('t', MetaData(), c1, c2)
+
+ self.assert_compile(
+ s3,
+ "SELECT t.c2 FROM t"
)
def test_from_list_with_columns(self):
@@ -471,18 +469,17 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
c1 = Column('c1', Integer)
s = select([c1])
- # force a compile.
- eq_(str(s), "SELECT c1")
+ # force a compile.
+ self.assert_compile(
+ s,
+ "SELECT c1"
+ )
- # this will emit a warning
- assert_raises_message(
- exc.SAWarning,
- r"\<class 'sqlalchemy.schema.Table'\> being associated "
- r"with \<class 'sqlalchemy.schema.Column'\> object after "
- r"the \<class 'sqlalchemy.schema.Column'\> has already "
- r"been used in a SQL generation; previously "
- r"generated constructs may contain stale state.",
- Table, 't', MetaData(), c1
+ Table('t', MetaData(), c1)
+
+ self.assert_compile(
+ s,
+ "SELECT t.c1 FROM t"
)
def test_from_list_recovers_after_warning(self):
@@ -491,7 +488,7 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
s = select([c1])
- # force a compile.
+ # force a compile.
eq_(str(s), "SELECT c1")
@testing.emits_warning()
@@ -505,7 +502,7 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
# 's' has been baked. Can't afford
# not caching select._froms.
# hopefully the warning will clue the user
- self.assert_compile(s, "SELECT t.c1")
+ self.assert_compile(s, "SELECT t.c1 FROM t")
self.assert_compile(select([c1]), "SELECT t.c1 FROM t")
self.assert_compile(select([c2]), "SELECT t.c2 FROM t")