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
This commit is contained in:
Eli Ribble 2016-07-05 16:36:59 -06:00
parent 500787fbd6
commit 6e448640b7
1 changed files with 3 additions and 2 deletions

View File

@ -11,10 +11,11 @@ import vanth.tables
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
def _select(): def _select():
my_max = sqlalchemy.sql.functions.max(vanth.tables.OFXUpdate.c.created)
subselect = sqlalchemy.select([ subselect = sqlalchemy.select([
vanth.tables.OFXUpdate.c.ofxaccount, vanth.tables.OFXUpdate.c.ofxaccount,
sqlalchemy.sql.functions.max(vanth.tables.OFXUpdate.c.created), my_max,
]).group_by( ]).limit(1).group_by(
vanth.tables.OFXUpdate.c.ofxaccount vanth.tables.OFXUpdate.c.ofxaccount
).alias('ofxupdates') ).alias('ofxupdates')
return sqlalchemy.select([ return sqlalchemy.select([