Added better relationship property handling

This commit is contained in:
Konsta Vesterinen
2013-09-29 19:28:21 +03:00
parent 7f699dd472
commit 084fb5e866
2 changed files with 8 additions and 1 deletions

View File

@@ -94,7 +94,9 @@ class QuerySorter(object):
expr = property_.columns[0].name
else:
expr = sort_expression(entity, property_.key)
return expr
return expr
else:
return
if isinstance(entity, AliasedInsp):
entity = entity.entity

View File

@@ -109,6 +109,11 @@ class TestSortQuery(TestCase):
sorted_query = sort_query(query, '-article_count')
assert 'article_count DESC' in str(sorted_query)
def test_relationship_property(self):
query = self.session.query(self.Category)
query = sort_query(query, 'articles')
assert 'ORDER BY' not in str(query)
def test_hybrid_property(self):
query = self.session.query(self.Category)
query = sort_query(query, 'articles_count')