Remove custom GMQuery class
We provided a custom GMQuery class that offered a .sort() method for compatibility with the Mongo syntax. Now that we have settled for sqlalchemy which uses the order_by() method, we can safely remove this custom class and move a little closer to "pure" and native sqlalchemy usage. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
39dc3bf8db
commit
20be9bb77d
@ -17,21 +17,8 @@
|
||||
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker, object_session
|
||||
from sqlalchemy.orm.query import Query
|
||||
|
||||
def _get_query_model(query):
|
||||
cols = query.column_descriptions
|
||||
assert len(cols) == 1, "These functions work only on simple queries"
|
||||
return cols[0]["type"]
|
||||
|
||||
|
||||
class GMGQuery(Query):
|
||||
def sort(self, key):
|
||||
key_col = getattr(_get_query_model(self), key)
|
||||
return self.order_by(key_col)
|
||||
|
||||
|
||||
Session = scoped_session(sessionmaker(query_cls=GMGQuery))
|
||||
Session = scoped_session(sessionmaker())
|
||||
|
||||
|
||||
class GMGTableBase(object):
|
||||
|
@ -514,7 +514,7 @@ def collection_atom_feed(request):
|
||||
|
||||
cursor = CollectionItem.query.filter_by(
|
||||
collection=collection.id) \
|
||||
.sort(CollectionItem.added.desc()) \
|
||||
.order_by(CollectionItem.added.desc()) \
|
||||
.limit(ATOM_DEFAULT_NR_OF_UPDATED_ITEMS)
|
||||
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user