Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 2.x #553 +/- ##
============================================
+ Coverage 91.73% 91.75% +0.02%
- Complexity 1924 1962 +38
============================================
Files 123 131 +8
Lines 4958 5031 +73
============================================
+ Hits 4548 4616 +68
- Misses 410 415 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c3a9933 to
a6ffc69
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Load Options DTO — Summary
Motivation
Select::load()historically accepted raw arrays for configuration. This made the API non-discoverable:the user had to know key names, valid value types, and which options apply to which relation type.
The DTO approach replaces untyped arrays with typed objects — one per relation type — where every option
is a named constructor parameter with a default value, a type, and a docblock.
Array syntax is still supported for backwards compatibility.
DTO Hierarchy
All classes live in
Cycle\ORM\Select\Options.Enums
LoadMethodSingleQuery (1),OuterQuery (2)JoinMethodInnerJoin (3),LeftJoin (4)$methodacceptsLoadMethod|JoinMethod|null.Table Override (
$table)Every DTO exposes
?string $table(@var non-empty-string|null).When set, the loader reads data from the specified table instead of the one defined in schema.
Use case — loading from an archive:
The option is available for all relation types except
BelongsToMorphed(target is resolved dynamically by discriminator).
toArray()MappingEach DTO implements
toArray(): arraythat converts to the legacy options format understood by loaders.Null-valued optional fields are omitted so they don't override schema-defined defaults
(loaders merge via
$options + $this->options).Integration Points
Select::load()LoadOptions|arrayas second argumentAbstractLoader::loadRelation()$options->toArray()ManyToManyLoader::loadRelation()LoadOptions|arrayChainTrait::loadRelation()Tests
Unit Tests (
tests/ORM/Unit/Select/Options/)One test class per DTO + enum. Cover constructor defaults,
toArray()output, enum values.Functional Tests (
tests/ORM/Functional/Driver/Common/Relation/)Each abstract test class has driver-specific subclasses for SQLite, MySQL, Postgres, SQLServer.