Skip to content

Return full OUTPUT row for composite primary key inserts#1389

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/fix-issue-1353
Draft

Return full OUTPUT row for composite primary key inserts#1389
Copilot wants to merge 1 commit into
mainfrom
copilot/fix-issue-1353

Conversation

Copilot AI commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

SQL Server inserts with composite primary keys were not assigning all database-generated key parts back to the created Active Record instance. In practice, only part of the returned key data was applied, leaving generated components (e.g., uniqueidentifier) unset on the in-memory record.

  • Adapter behavior change

    • Override SQL Server returning_column_values to return the full first returned row, not a single scalar.
    • This aligns insert-return handling with multi-column OUTPUT INSERTED... payloads used for composite keys.
  • Regression coverage

    • Add a targeted test for a table with composite PK (id IDENTITY, guid DEFAULT NEWID()).
    • Assert that create! assigns both generated PK components (id and guid) to the created instance.
# SQL Server adapter: preserve all returned columns for insert RETURNING/OUTPUT
def returning_column_values(result)
  result.rows.first
end

Copilot AI changed the title Fix composite primary key assignment on create Return full OUTPUT row for composite primary key inserts Jun 7, 2026
Copilot AI requested a review from aidanharan June 7, 2026 11:51
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