Fix ambiguous column sorting
This commit is contained in:
@@ -508,10 +508,11 @@ def get_all_descriptors(expr):
|
|||||||
insp = sa.inspect(expr)
|
insp = sa.inspect(expr)
|
||||||
polymorphic_mappers = get_polymorphic_mappers(insp)
|
polymorphic_mappers = get_polymorphic_mappers(insp)
|
||||||
if polymorphic_mappers:
|
if polymorphic_mappers:
|
||||||
|
attrs = dict(get_mapper(expr).all_orm_descriptors)
|
||||||
attrs = {}
|
|
||||||
for submapper in polymorphic_mappers:
|
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 attrs
|
||||||
return get_mapper(expr).all_orm_descriptors
|
return get_mapper(expr).all_orm_descriptors
|
||||||
|
|
||||||
|
@@ -273,6 +273,13 @@ class TestSortQueryWithPolymorphicInheritance(TestCase):
|
|||||||
)
|
)
|
||||||
assert_contains('ORDER BY article.category ASC', query)
|
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):
|
class TestSortQueryWithCustomPolymorphic(TestCase):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user