Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/appendices/5-4-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ version is reported as `unknown`), the header is omitted.
- The default eager loading strategy for `HasMany` and `BelongsToMany` associations
has changed from `select` to `subquery`. If you need the previous behavior,
explicitly set `'strategy' => 'select'` when defining associations.
See [Associations](../orm/associations#has-many-associations) for more details.

### Controller

Expand Down
14 changes: 10 additions & 4 deletions docs/en/orm/associations.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,12 @@ Possible keys for hasMany association arrays include:
- **propertyName**: The property name that should be filled with data from the
associated table into the source table results. By default, this is the
underscored & plural name of the association so `comments` in our example.
- **strategy**: Defines the query strategy to use. Defaults to 'subquery'. The
other valid value is 'select', which uses the `IN` list of parent keys
- **strategy**: Defines the query strategy to use. Defaults to `subquery`. The
other valid value is `select`, which uses the `IN` list of parent keys
directly instead of a subquery.
::: tip New default strategy in version 5.4+
The default strategy has changed from `select` to `subquery` in order to improve performance when the number of parent keys is large.
:::
- **saveStrategy**: Either `append` or `replace`. Defaults to `append`. When `append` the current
records are appended to any records in the database. When `replace` associated
records not in the current set will be removed. If the foreign key is a nullable
Expand Down Expand Up @@ -616,9 +619,12 @@ Possible keys for belongsToMany association arrays include:
- **propertyName**: The property name that should be filled with data from the
associated table into the source table results. By default, this is the
underscored & plural name of the association, so `tags` in our example.
- **strategy**: Defines the query strategy to use. Defaults to 'subquery'. The
other valid value is 'select', which uses the `IN` list of parent keys
- **strategy**: Defines the query strategy to use. Defaults to `subquery`. The
other valid value is `select`, which uses the `IN` list of parent keys
directly instead of a subquery.
::: tip New default strategy in version 5.4+
The default strategy has changed from `select` to `subquery` in order to improve performance when the number of parent keys is large.
:::
- **saveStrategy**: Either `append` or `replace`. Defaults to `replace`.
Indicates the mode to be used for saving associated entities. The former will
only create new links between both side of the relation and the latter will
Expand Down