diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-29 12:05:00 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-29 12:05:00 -0400 |
commit | fbcb056d90f4a54eed7cf270818c9a1fc173f99f (patch) | |
tree | e095fb7b11a76ea152595b561f79222896b76b1d /test/orm/inheritance/test_single.py | |
parent | 08d2c863df04f954f305b460bba45b15a410fc74 (diff) | |
download | sqlalchemy-fbcb056d90f4a54eed7cf270818c9a1fc173f99f.tar.gz |
- Changed the approach by which the "single inheritance criterion"
is applied, when using :meth:`.Query.from_self`, or its common
user :meth:`.Query.count`. The criteria to limit rows to those
with a certain type is now indicated on the inside subquery,
not the outside one, so that even if the "type" column is not
available in the columns clause, we can filter on it on the "inner"
query.
fixes #3177
Diffstat (limited to 'test/orm/inheritance/test_single.py')
-rw-r--r-- | test/orm/inheritance/test_single.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/orm/inheritance/test_single.py b/test/orm/inheritance/test_single.py index 434642ca1..23b1c4fd2 100644 --- a/test/orm/inheritance/test_single.py +++ b/test/orm/inheritance/test_single.py @@ -149,11 +149,24 @@ class SingleInheritanceTest(testing.AssertsCompiledSQL, fixtures.MappedTest): 'employees_manager_data, ' 'employees.engineer_info AS ' 'employees_engineer_info, employees.type ' - 'AS employees_type FROM employees) AS ' - 'anon_1 WHERE anon_1.employees_type IN ' - '(:type_1, :type_2)', + 'AS employees_type FROM employees WHERE ' + 'employees.type IN (:type_1, :type_2)) AS ' + 'anon_1', use_default_dialect=True) + def test_from_self_count(self): + Engineer = self.classes.Engineer + + sess = create_session() + col = func.count(literal_column('*')) + self.assert_compile( + sess.query(Engineer.employee_id).from_self(col), + "SELECT count(*) AS count_1 " + "FROM (SELECT employees.employee_id AS employees_employee_id " + "FROM employees " + "WHERE employees.type IN (?, ?)) AS anon_1" + ) + def test_select_from(self): Manager, JuniorEngineer, employees, Engineer = (self.classes.Manager, self.classes.JuniorEngineer, |