Skip to content

Commit 44cdf9b

Browse files
author
Paula Bianca Torre
committed
Update regex for RecordNotUnique exception
Fixes issue #256 `TinyTds::Error: Violation of UNIQUE KEY constraint '<constraint_name>'. Cannot insert duplicate key in object ...` does not match the regex for `RecordNotUnique` exception. Signed-off-by: Paula Bianca Torre <paula.torre@teamcodeflux.com>
1 parent 00d3dbb commit 44cdf9b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def cs_equality_operator
389389

390390
def translate_exception(e, message)
391391
case message
392-
when /cannot insert duplicate key .* with unique index/i
392+
when /(cannot insert duplicate key .* with unique index) | (violation of unique key constraint)/i
393393
RecordNotUnique.new(message,e)
394394
when /conflicted with the foreign key constraint/i
395395
InvalidForeignKey.new(message,e)

0 commit comments

Comments
 (0)