summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-05-23 21:11:50 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-05-23 21:11:50 +0000
commit56f302138622b868a9f6fc63d4f080e5c237dd3e (patch)
tree294dda86754234fcf9765a09157560fd382e88cc /test
parent330381a3312394d9663d157182cf97cea8b43fcc (diff)
parent8c10e29dc7aa2356d0f3f5110b2c9dade9d87096 (diff)
downloadsqlalchemy-56f302138622b868a9f6fc63d4f080e5c237dd3e.tar.gz
Merge "Improve error message when using :meth:`_query.Query.filter_by` in a query where the first entity is not a mapped class."
Diffstat (limited to 'test')
-rw-r--r--test/orm/test_query.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/orm/test_query.py b/test/orm/test_query.py
index 150b406e7..8943bfc1f 100644
--- a/test/orm/test_query.py
+++ b/test/orm/test_query.py
@@ -3345,6 +3345,18 @@ class FilterTest(QueryTest, AssertsCompiledSQL):
"AS users_name FROM users WHERE name='ed'",
)
+ def test_filter_by_non_entity(self):
+ s = create_session()
+ e = sa.func.count(123)
+ assert_raises_message(
+ sa_exc.InvalidRequestError,
+ r"Can't use filter_by when the first entity 'count\(:count_1\)' of"
+ " a query is not a mapped class. Please use the filter method "
+ "instead, or change the order of the entities in the query",
+ s.query(e).filter_by,
+ col=42,
+ )
+
class HasAnyTest(fixtures.DeclarativeMappedTest, AssertsCompiledSQL):
__dialect__ = "default"