Skip to content

Commit

Permalink
[ckan#3816] show query errors on form
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi authored and jguo144 committed Jul 5, 2018
1 parent 85b3cda commit 1e86c42
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions ckanext/datastore/backend/postgres.py
Expand Up @@ -1504,11 +1504,10 @@ def _remove_explain(msg):
.replace('EXPLAIN ', ''))

raise ValidationError({
'query': [_remove_explain(str(e))],
'sql': [_remove_explain(str(e.orig))],
'info': {
'statement': [_remove_explain(e.statement)],
'params': [e.params],
'orig': [_remove_explain(str(e.orig))]
}
})
except DBAPIError, e:
Expand Down
4 changes: 2 additions & 2 deletions ckanext/datastore/logic/action.py
Expand Up @@ -111,10 +111,10 @@ def datastore_create(context, data_dict):
{'sql': materialized_view_sql, 'dry_run': True})
except p.toolkit.ValidationError as e:
raise p.toolkit.ValidationError(
{'datastore_search_sql': e.error_dict['sql']})
{'materialized_view_sql': e.error_dict['sql']})
except p.toolkit.NotAuthorized as e:
raise p.toolkit.ValidationError(
{'datastore_search_sql': e.message})
{'materialized_view_sql': e.message})

if 'resource' in data_dict and 'resource_id' in data_dict:
raise p.toolkit.ValidationError({
Expand Down
2 changes: 1 addition & 1 deletion ckanext/datastore/plugin.py
Expand Up @@ -280,7 +280,7 @@ def datastore_resource_query(value):
None,
{'sql': value, 'dry_run': True})
except p.toolkit.ValidationError as e:
raise p.toolkit.Invalid(e['sql'])
raise p.toolkit.Invalid(e.error_dict['sql'])
except p.toolkit.NotAuthorized as e:
raise p.toolkit.Invalid(e.message)
return value

0 comments on commit 1e86c42

Please sign in to comment.