Jonas Haag  committed 81c7e4b

Prefer IntegrityError over DatabaseError in case of an integrity error.

  • Participants
  • Parent commits 1f9aeac

Comments (0)

Files changed (1)

File djangotoolbox/db/

             if value is NOT_PROVIDED:
                 value = field.get_default()
             if value is None and not field.null:
-                raise DatabaseError("Non-nullable field %s can't be None!" %
+                raise IntegrityError("Non-nullable field %s can't be None!" %
             value = self.convert_value_from_db(field.db_type(connection=self.connection), value)
         return result
         for (field, value), column in zip(self.query.values, self.query.columns):
             if field is not None:
                 if not field.null and value is None:
-                    raise DatabaseError("You can't set %s (a non-nullable "
+                    raise IntegrityError("You can't set %s (a non-nullable "
                                         "field) to None!" %
                 db_type = field.db_type(connection=self.connection)
                 value = self.convert_value_for_db(db_type, value)