Skip to content

Commit 6cc4db6

Browse files
committed
Add ActiveRecord::CheckViolation error class for check constraint violations.
Ref: rails/rails@2cffe06
1 parent 0c779df commit 6cc4db6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ def translate_exception(exception, message:, sql:, binds:)
495495
NotNullViolation.new(message, sql: sql, binds: binds, connection_pool: @pool)
496496
when /Arithmetic overflow error/
497497
RangeError.new(message, sql: sql, binds: binds, connection_pool: @pool)
498+
when /statement conflicted with the CHECK constraint/
499+
CheckViolation.new(message, sql: sql, binds: binds, connection_pool: @pool)
498500
else
499501
super
500502
end

0 commit comments

Comments
 (0)