commit a416402b0a4c6b5406448a5f87538081f26d9368 Author: aagbsn aagbsn@extc.org Date: Thu Apr 21 18:28:17 2011 -0700
rewrite query for mysql compatibility attempt 1 --- SQLSupport.py | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/SQLSupport.py b/SQLSupport.py index 9e1a4cb..8ef8b68 100644 --- a/SQLSupport.py +++ b/SQLSupport.py @@ -405,9 +405,18 @@ class RouterStats(Entity): #min_avg_rank = select([func.min(RouterStats.avg_rank)]).as_scalar() max_avg_rank = select([func.max(RouterStats.avg_rank)]).as_scalar()
+ # this query breaks MySQL! + #RouterStats.table.update(values= + # {RouterStats.table.c.percentile: + # (100.0*RouterStats.table.c.avg_rank)/max_avg_rank}).execute() + + # I think the problem is the reference to RouterStats.table.c.avg_rank -- let's just replace it with the query used above. I think the nested query will be OK + #query('UPDATE routerstats SET percentile=((%s * routerstats.avg_rank) / (SELECT max(routerstats.avg_rank) AS max_1 \nFROM routerstats))' (100.0,)) RouterStats.table.update(values= {RouterStats.table.c.percentile: - (100.0*RouterStats.table.c.avg_rank)/max_avg_rank}).execute() + (100.0*avg_r)/max_avg_rank}).execute() + + tc_session.commit() _compute_ranks = Callable(_compute_ranks)
tor-commits@lists.torproject.org