Skip to content

Commit 1a5ce97

Browse files
committed
Fixed joins as it was incorrectly duplicating the identity column.
1 parent 5d2b384 commit 1a5ce97

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ def column_definitions(table_name)
190190
AND s.schema_id = s.schema_id
191191
INNER JOIN #{db_name_with_period}.sys.objects AS o
192192
ON s.schema_id = o.schema_id
193-
INNER JOIN #{db_name_with_period}.sys.columns AS c
194-
ON o.object_id = c.object_id
195193
AND o.is_ms_shipped = 0
196194
AND o.type = 'U'
195+
AND o.name = columns.TABLE_NAME
196+
INNER JOIN #{db_name_with_period}.sys.columns AS c
197+
ON o.object_id = c.object_id
197198
AND c.name = columns.COLUMN_NAME
198199
WHERE columns.TABLE_NAME = @0
199200
AND columns.TABLE_SCHEMA = #{table_schema.blank? ? "schema_name()" : "@1"}

0 commit comments

Comments
 (0)