Skip to content

Commit

Permalink
Merge pull request #4583 from ckan/better-datastore-validation-error
Browse files Browse the repository at this point in the history
Return message from Postgres when there's a validation during datastore import
  • Loading branch information
wardi committed Dec 10, 2018
2 parents a4ec78e + 92ea0c6 commit 5ce4ae9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ckanext/datastore/backend/postgres.py
Expand Up @@ -1054,11 +1054,10 @@ def upsert_data(context, data_dict):

try:
context['connection'].execute(sql_string, rows)
except sqlalchemy.exc.DataError:
except sqlalchemy.exc.DataError as err:
raise InvalidDataError(
toolkit._("The data was invalid (for example: a numeric value "
"is out of range or was inserted into a text field)."
))
toolkit._("The data was invalid: {}"
).format(_programming_error_summary(err)))
except sqlalchemy.exc.DatabaseError as err:
raise ValidationError(
{u'records': [_programming_error_summary(err)]})
Expand Down

0 comments on commit 5ce4ae9

Please sign in to comment.