From 6e448640b70e071dd32bce45db4835781751bb35 Mon Sep 17 00:00:00 2001
From: Eli Ribble <eli@authentise.com>
Date: Tue, 5 Jul 2016 16:36:59 -0600
Subject: [PATCH] Fix sql to return fewer results in subquery

Yay for the limit 1. I also fixed a bug I accidentally introduced when
cleaning up my debug statements
---
 vanth/platform/ofxaccount.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vanth/platform/ofxaccount.py b/vanth/platform/ofxaccount.py
index 145c4b4..a625223 100644
--- a/vanth/platform/ofxaccount.py
+++ b/vanth/platform/ofxaccount.py
@@ -11,10 +11,11 @@ import vanth.tables
 LOGGER = logging.getLogger(__name__)
 
 def _select():
+    my_max = sqlalchemy.sql.functions.max(vanth.tables.OFXUpdate.c.created)
     subselect = sqlalchemy.select([
         vanth.tables.OFXUpdate.c.ofxaccount,
-        sqlalchemy.sql.functions.max(vanth.tables.OFXUpdate.c.created),
-    ]).group_by(
+        my_max,
+    ]).limit(1).group_by(
         vanth.tables.OFXUpdate.c.ofxaccount
     ).alias('ofxupdates')
     return sqlalchemy.select([