Skip to content

Commit

Permalink
Return message from Postgres when there's a validation during import
Browse files Browse the repository at this point in the history
Right now when there's a validation error during datastore_create you
just get a generic message with no actual details (eg wrong type or
wrong values). At least let's return Postgres message which gives the
column and/or the wrong value.
  • Loading branch information
amercader committed Dec 9, 2018
1 parent 78a4022 commit 92ea0c6
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 92ea0c6

Please sign in to comment.