Skip to content

Commit

Permalink
Fixes #2007
Browse files Browse the repository at this point in the history
In the plugins before_show the datastore_active flag in the resource
dict would not be set if the sql query generated an exception.  This had
implications with pg 8.4 where the flag was not present because of a
query failure, but it was checked for in tests.

Have set the default to false and just overwrite it if the query does
not explode and if it returns a result.
  • Loading branch information
rossjones committed Nov 19, 2014
1 parent 0ddd6fd commit 3b87cc0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ckanext/datastore/plugin.py
Expand Up @@ -273,6 +273,9 @@ def before_show(self, resource_dict):
action='dump', resource_id=resource_dict['id'])

connection = None

resource_dict['datastore_active'] = False

try:
connection = self.read_engine.connect()
result = connection.execute(
Expand All @@ -281,8 +284,6 @@ def before_show(self, resource_dict):
).fetchone()
if result:
resource_dict['datastore_active'] = True
else:
resource_dict['datastore_active'] = False
finally:
if connection:
connection.close()
Expand Down

0 comments on commit 3b87cc0

Please sign in to comment.