Skip to content

Commit

Permalink
fix: Update default refential action values. (#221)
Browse files Browse the repository at this point in the history
* fix: Document all default referential values.

* fix: Apply same fix to versioned documentation.
  • Loading branch information
SandPod authored Dec 10, 2024
1 parent 37792ca commit c783a46
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ Use the following syntax to apply referential actions
relation(onUpdate=<ACTION>, onDelete=<ACTION>)
```

For instance, the default behavior in Serverpod can be expressed as.
## Default values
If no referential actions are specified, the default behavior will be applied.

If the relation is defined as an [object relation](one-to-one#with-an-object), the default behavior is `NoAction` for both onUpdate and onDelete.

```yaml
parent: Model?, relation(onUpdate=NoAction, onDelete=NoAction)
```
If the relation is defined as an [id relation](one-to-one#with-an-id-field), the default behavior is `NoAction` for onUpdate and `Cascade` for onDelete.


```yaml
relation(onUpdate=NoAction, onDelete=Cascade)
parentId: int?, relation(parent=model_table, onUpdate=NoAction, onDelete=Cascade)
```

:::info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ Use the following syntax to apply referential actions
relation(onUpdate=<ACTION>, onDelete=<ACTION>)
```

For instance, the default behavior in Serverpod can be expressed as.
## Default values
If no referential actions are specified, the default behavior will be applied.

If the relation is defined as an [object relation](one-to-one#with-an-object), the default behavior is `NoAction` for both onUpdate and onDelete.

```yaml
relation(onUpdate=NoAction, onDelete=Cascade)
parent: Model?, relation(onUpdate=NoAction, onDelete=NoAction)
```
If the relation is defined as an [id relation](one-to-one#with-an-id-field), the default behavior is `NoAction` for onUpdate and `Cascade` for onDelete.


```yaml
parentId: int?, relation(parent=model_table, onUpdate=NoAction, onDelete=Cascade)
```

:::info

The sequence of onUpdate and onDelete is interchangeable.
Expand All @@ -41,4 +53,3 @@ fields:
```

In the given example, if the `example` parent is updated, the `parentId` will be set to null. If the parent is deleted, no action will be taken for parentId.

Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ Use the following syntax to apply referential actions
relation(onUpdate=<ACTION>, onDelete=<ACTION>)
```

For instance, the default behavior in Serverpod can be expressed as.
## Default values
If no referential actions are specified, the default behavior will be applied.

If the relation is defined as an [object relation](one-to-one#with-an-object), the default behavior is `NoAction` for both onUpdate and onDelete.

```yaml
parent: Model?, relation(onUpdate=NoAction, onDelete=NoAction)
```
If the relation is defined as an [id relation](one-to-one#with-an-id-field), the default behavior is `NoAction` for onUpdate and `Cascade` for onDelete.


```yaml
relation(onUpdate=NoAction, onDelete=Cascade)
parentId: int?, relation(parent=model_table, onUpdate=NoAction, onDelete=Cascade)
```

:::info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ Use the following syntax to apply referential actions
relation(onUpdate=<ACTION>, onDelete=<ACTION>)
```

For instance, the default behavior in Serverpod can be expressed as.
## Default values
If no referential actions are specified, the default behavior will be applied.

If the relation is defined as an [object relation](one-to-one#with-an-object), the default behavior is `NoAction` for both onUpdate and onDelete.

```yaml
parent: Model?, relation(onUpdate=NoAction, onDelete=NoAction)
```
If the relation is defined as an [id relation](one-to-one#with-an-id-field), the default behavior is `NoAction` for onUpdate and `Cascade` for onDelete.


```yaml
relation(onUpdate=NoAction, onDelete=Cascade)
parentId: int?, relation(parent=model_table, onUpdate=NoAction, onDelete=Cascade)
```

:::info
Expand Down

0 comments on commit c783a46

Please sign in to comment.