Fix ambiguous column sorting
This commit is contained in:
@@ -508,10 +508,11 @@ def get_all_descriptors(expr):
|
||||
insp = sa.inspect(expr)
|
||||
polymorphic_mappers = get_polymorphic_mappers(insp)
|
||||
if polymorphic_mappers:
|
||||
|
||||
attrs = {}
|
||||
attrs = dict(get_mapper(expr).all_orm_descriptors)
|
||||
for submapper in polymorphic_mappers:
|
||||
attrs.update(submapper.all_orm_descriptors)
|
||||
for key, descriptor in submapper.all_orm_descriptors.items():
|
||||
if key not in attrs:
|
||||
attrs[key] = descriptor
|
||||
return attrs
|
||||
return get_mapper(expr).all_orm_descriptors
|
||||
|
||||
|
@@ -273,6 +273,13 @@ class TestSortQueryWithPolymorphicInheritance(TestCase):
|
||||
)
|
||||
assert_contains('ORDER BY article.category ASC', query)
|
||||
|
||||
def test_with_ambiguous_column(self):
|
||||
query = sort_query(
|
||||
self.session.query(self.TextItem),
|
||||
'id'
|
||||
)
|
||||
assert_contains('ORDER BY text_item.id ASC', query)
|
||||
|
||||
|
||||
class TestSortQueryWithCustomPolymorphic(TestCase):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user