Skip to content

fix: fix isUniqueConstraintError to catch SQL Server error 2627#60320

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
ErfanMomeniii:13.x
May 29, 2026
Merged

fix: fix isUniqueConstraintError to catch SQL Server error 2627#60320
taylorotwell merged 1 commit into
laravel:13.xfrom
ErfanMomeniii:13.x

Conversation

@ErfanMomeniii
Copy link
Copy Markdown
Contributor

Hi @taylorotwell, SqlServerConnection::isUniqueConstraintError only caught error 2601 but missed error 2627 because the regex required "row" in the message. Error 2601 says "Cannot insert duplicate key row in object" while 2627 says "Cannot insert duplicate key in object" (no "row"). This caused UNIQUE KEY and PRIMARY KEY constraint violations to throw a generic QueryException instead of UniqueConstraintViolationException. Fixed by making "row" optional.

https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-2000-to-2999

@taylorotwell taylorotwell merged commit 1bfaa46 into laravel:13.x May 29, 2026
22 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants