Translate NOT NULL violation to the specific exception #25451

Merged
merged 1 commit into from Dec 6, 2016

Projects

None yet

6 participants

@kamipo
Member
kamipo commented Jun 20, 2016 edited

Raise ActiveRecord::NotNullViolation when a record cannot be inserted
or updated because it would violate a not null constraint.

@matthewd matthewd was assigned by rails-bot Jun 20, 2016
@rails-bot

r? @matthewd

(@rails-bot has picked a reviewer for you, use r? to override)

@@ -733,6 +733,8 @@ def add_options_for_index_columns(quoted_columns, **options)
# See https://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html
ER_DUP_ENTRY = 1062
+ ER_NOT_NULL_VIOLATION = 1048
+ ER_DO_NOT_HAVE_DEFUALT = 1364
@alepore
alepore Dec 6, 2016

DEFUALT => DEFAULT

@kamipo
kamipo Dec 6, 2016 Member

Oh... thanks!

@kamipo kamipo Translate NOT NULL violation to the specific exception
Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted
or updated because it would violate a not null constraint.
b270bc4
@sgrif sgrif merged commit cf6c294 into rails:master Dec 6, 2016

2 checks passed

codeclimate Code Climate didn't find any new or fixed issues.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kamipo kamipo deleted the kamipo:translate_not_null_violation_to_specific_exception branch Dec 6, 2016
@kamipo kamipo added a commit to kamipo/rails that referenced this pull request Dec 9, 2016
@kamipo kamipo Add a changelog entry for #25451 [ci skip] 3190aab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment