From a290c07f613a9394698c33df4e67dcddc71d0840 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sun, 10 Nov 2013 20:41:14 +0100 Subject: [PATCH] Fixed month order. --- src/api/controller/accounts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/controller/accounts.py b/src/api/controller/accounts.py index 8ef7102..7d69229 100644 --- a/src/api/controller/accounts.py +++ b/src/api/controller/accounts.py @@ -54,8 +54,8 @@ def get_months(account_id): session = db.session query = session.query( - distinct(cast(extract("year", Entry.operation_date), db.String)).label("year"), - cast(extract("month", Entry.operation_date), db.String).label("month") + distinct(func.lpad(cast(extract("year", Entry.operation_date), db.String), 4, '0')).label("year"), + func.lpad(cast(extract("month", Entry.operation_date), db.String), 2, '0').label("month") ).filter(Entry.account_id == account_id).order_by("year", "month") return json.dumps([{