Skip to content

Conversation

@aidanharan
Copy link
Contributor

@aidanharan aidanharan commented Aug 30, 2021

Creating a record that violates a primary key constraint should throw an ActiveRecord::RecordNotUnique error rather than the generic ActiveRecord::StatementInvalid error.

The issue was caused by how the adapter was translating MSSQL errors into ActiveRecord errors. We were handling unique key violations but not primary key violations.

Fixes #939

@aidanharan aidanharan marked this pull request as ready for review August 30, 2021 16:45
@wpolicarpo wpolicarpo merged commit b7e52f7 into rails-sqlserver:main Aug 31, 2021
lavika pushed a commit to lavika/activerecord-sqlserver-adapter that referenced this pull request Sep 26, 2023
…qlserver#940)

* Primary key violation should result in ActiveRecord::RecordNotUnique error

* Updated changelog

Co-authored-by: Aidan Haran <aharan@fusioneer.com>
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.

ActiveRecord::StatementInvalid raised in case of duplicate key

2 participants