Fix analyze function for PostgreSQL 9.4

This commit is contained in:
Konsta Vesterinen
2015-01-12 09:50:15 +02:00
parent 4c8e7b7dbb
commit 2feeec234c
2 changed files with 15 additions and 1 deletions

View File

@@ -4,6 +4,12 @@ Changelog
Here you can see the full list of changes between each SQLAlchemy-Utils release.
0.29.3 (2015-xx-xx)
^^^^^^^^^^^^^^^^^^^
- Fixed analyze function runtime property handling for PostgreSQL >= 9.4
0.29.2 (2015-01-08)
^^^^^^^^^^^^^^^^^^^

View File

@@ -26,7 +26,15 @@ class PlanAnalysis(object):
class QueryAnalysis(object):
def __init__(self, result_set):
self.plan = result_set[0]['Plan']
self.runtime = result_set[0]['Total Runtime']
if 'Total Runtime' in result_set[0]:
# PostgreSQL versions < 9.4
self.runtime = result_set[0]['Total Runtime']
else:
# PostgreSQL versions >= 9.4
self.runtime = (
result_set[0]['Execution Time'] +
result_set[0]['Planning Time']
)
@property
def node_types(self):