summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/assertions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-03-05 16:02:38 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-03-05 16:06:26 -0500
commit8b8a4c373e1cec2203f73b1772704b9ded75c1fe (patch)
treea9129521118f2b4a54bd1c912c9e9497b47371b6 /lib/sqlalchemy/testing/assertions.py
parent2929d5a1e08e9bd1f12d5a1a059018bf92ef6e29 (diff)
downloadsqlalchemy-8b8a4c373e1cec2203f73b1772704b9ded75c1fe.tar.gz
Ensure all Query statements compile w/ orm, fix test harness
Fixed regression where :meth:`_orm.Query.join` would produce no effect if the query itself as well as the join target were against a :class:`_schema.Table` object, rather than a mapped class. This was part of a more systemic issue where the legacy ORM query compiler would not be correctly used from a :class:`_orm.Query` if the statement produced had not ORM entities present within it. Also repair the assert_compile() method, which was using Query._compile_state() which was bypassing the bug. A handful of ORM tests with Query objects and Core-only objects were actually failing if the default compilation path were used. Fixes: #6003 Change-Id: I97478b2d06bf6c01fe1f09ee118e1f2ac4c849bc
Diffstat (limited to 'lib/sqlalchemy/testing/assertions.py')
-rw-r--r--lib/sqlalchemy/testing/assertions.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py
index 81c74e7c1..289ac9a0a 100644
--- a/lib/sqlalchemy/testing/assertions.py
+++ b/lib/sqlalchemy/testing/assertions.py
@@ -445,11 +445,9 @@ class AssertsCompiledSQL(object):
from sqlalchemy import orm
if isinstance(clause, orm.Query):
- compile_state = clause._compile_state()
- compile_state.statement._label_style = (
- LABEL_STYLE_TABLENAME_PLUS_COL
- )
- clause = compile_state.statement
+ stmt = clause._statement_20()
+ stmt._label_style = LABEL_STYLE_TABLENAME_PLUS_COL
+ clause = stmt
if compile_kwargs:
kw["compile_kwargs"] = compile_kwargs