You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix deteministic fetch when table has a composite primary key (#936)
Even though Rails does not support tables with primary keys, it still allows
those tables to be defined without any problems.
The SQL Server adapter will always try to retrieve records in a deterministic
way but it currently fails if the table has a composite primary key, which
shouldn't happen.
This PR fixes how the adapter determines which column (generally the PK) is
used as the default order when multiple primary keys are detected.
It first checks if one of the primary keys is also an identity column. If
there's an identity column, it will choose it as the "main primary key",
otherwise it will just fallback to the first of the primary keys.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
-[#933](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/933) Conditionally apply SQL Server monkey patches to ActiveRecord so that it is safe to use this gem alongside other database adapters (e.g. PostgreSQL) in a multi-database Rails app
Copy file name to clipboardExpand all lines: test/schema/sqlserver_specific_schema.rb
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -294,4 +294,22 @@
294
294
CONSTRAINT PK_UNIQUE_KEY PRIMARY KEY (id)
295
295
);
296
296
SQLSERVERUNIQUEKEYS
297
+
298
+
execute"IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'sst_composite_without_identity') DROP TABLE sst_composite_without_identity"
0 commit comments