Skip to content

fix(docs): correct spread order in defineRelationsPart example#679

Open
morgan-coded wants to merge 1 commit into
drizzle-team:mainfrom
morgan-coded:fix/relations-v2-spread-order-example
Open

fix(docs): correct spread order in defineRelationsPart example#679
morgan-coded wants to merge 1 commit into
drizzle-team:mainfrom
morgan-coded:fix/relations-v2-spread-order-example

Conversation

@morgan-coded
Copy link
Copy Markdown

The "Why it's important?" callout in the Relations Parts section of the Drizzle Relations (v2) docs shows the same spread order { ...relations, ...part } for both result objects — the one that keeps the relation and the one where "posts relations information will be lost". With identical spread orders the two outcomes are indistinguishable, which is the bug reported in #629.

defineRelations seeds an empty placeholder (posts: {}) for every table, and object spread is last-key-wins:

  • { ...relations, ...part }.posts{ author: {...} } (relation kept)
  • { ...part, ...relations }.posts{} (relation lost)

The second example is the "lost" case, so its spread order is corrected to { ...part, ...relations }.

Closes #629

The "Why it's important?" callout in the Relations Parts section showed the
same spread order `{ ...relations, ...part }` for both the kept and the lost
result objects, making the two outcomes indistinguishable.

The second example illustrates the case where the main relations object is
spread last, so its empty `posts: {}` placeholder overwrites the relation
defined in `part` ("posts relations information will be lost"). That outcome
corresponds to `{ ...part, ...relations }`, so the second snippet is updated to
use that order.

Closes drizzle-team#629

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 15:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Documentation fix correcting the spread order shown in an example explaining how relations and partial selections merge.

Changes:

  • Corrected the object spread order in an explanatory sentence from { ...relations, ...part } to { ...part, ...relations } to match the resulting JSON shown below it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Typo in defineRelationsPart docs: Incorrect spread syntax in explanation

2 participants