Skip to content

Commit eb33313

Browse files
docs(getting-started): fix swapped master_detail delete-behavior default (#9179)
common-patterns.mdx told authors master_detail defaults to deleteBehavior: set_null and that they must set cascade explicitly to get it. Both clauses are false, and the two defaults are swapped onto the wrong field type: - a master_detail field with no deleteBehavior cascades — set_null is not even reachable on that branch of the engine's resolution ternary (packages/objectql/src/engine.ts, cascadeDeleteRelations); - set_null is the default for the *other* branch: a plain reference (lookup) with no deleteBehavior. The harmful reading was the passive one: a reader who took the page at its word concluded their child rows were safe by default and changed nothing, then lost them silently on the next parent delete. This also contradicts the repo's own correct reference page, content/docs/protocol/objectql/types.mdx ("Always cascade" for master_detail). Corrected the sentence to match the engine and types.mdx, and added the reason cascade is the right default: a master_detail child has no independent existence. Docs-only; no engine change. Fixes #9164 Co-authored-by: Claude <noreply@anthropic.com>
1 parent fbb247c commit eb33313

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

content/docs/getting-started/common-patterns.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default defineStack({
9292

9393
## 2. Master-Detail Relationship
9494

95-
Create a parent-child relationship between a master and its detail records. Note that `master_detail` defaults to `deleteBehavior: 'set_null'`; set `deleteBehavior: 'cascade'` explicitly if you want child records deleted with the parent.
95+
Create a parent-child relationship between a master and its detail records. A `master_detail` child has no independent existence, so `master_detail` fields **cascade deletes by default** — deleting the parent deletes its children too. Set `deleteBehavior: 'restrict'` explicitly if you want the parent delete blocked while children still exist.
9696

9797
{/* os:check */}
9898
```typescript

0 commit comments

Comments
 (0)