-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW Use custom list for eagerloaded relations #10869
NEW Use custom list for eagerloaded relations #10869
Conversation
7bbe146
to
efe7852
Compare
1fffd4f
to
51bfa5e
Compare
58c7f1c
to
56d6bb4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of changes here so I'll probably need to do 2 or 3 rounds of review
On extra thing to add / add a test for is that when attempting to filter by something with a dot e.g. ->filter(['MyRelation.Title' => 'lorem'])
- we should be throwing an exception so that the developer is aware this isn't possible
We currently have this in the corresponding docs pr
"
Note also that EagerLoadedDataList
can't currently filter or sort by fields on relations using dot syntax (e.g. sort('MySubRelation.Title')
won't work), nor filter using SearchFilter
syntax (e.g. filter('Title:StartsWith', 'Prefix')
).
"
ae2857d
to
90c4ba3
Compare
Test added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's some missing unit tests in EagerLoadedListTest.php
EagerLoadedList public methods:
Has dedicated unit test
- dataClass
- getIterator
- toNestedArray
- map
- each
- max
- min
- avg
- sum
- canFilterBy
- canSortBy
- find
- filter
- filterAny
- exclude
- excludeAny
- addFilter
- subtract
- filterByCallback
- byID
- byIDs
- sort
- shuffle
- reverse
- limit
- has
Tested in other tests
- offsetGet
- add
- toArray
- first
- last
- column
- count
Not tested
- dbObject
- getIDList
- setByIDList
- forForeignID
- getRows
- remove
- columnUnique
- debug
- offsetExists
- relation
- createDataObject
- getExtraData
- getExtraFields
- exists
- offsetSet
- offsetUnset
90c4ba3
to
958c133
Compare
I've now added tests for those. I've changed the implementation of I've changed the API for I've also improved the Finally, I've swapped the order of arguments in the constructor - it is more intuitive to pass the dataclass first, I've found. This also means we can easily give a default for |
958c133
to
ea68fa6
Compare
ea68fa6
to
6397641
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main thing is strongly type all the things
6397641
to
5d0556d
Compare
Performance comparisons
The following comparison table was made using this code, where
Player
andTeam
are simpleDataObject
models, andTeam
has amany_many
relation toPlayer
.The database has 29
Team
records, each of which has 10Player
records.The times were recorded from the lekoala debugbar, which shows the total ms for db calls in the request. It necessarily includes some unrelated queries, but those queries are fixed so they don't affect the difference between implementations.
To get the values, I ran the above code 3 times for each scenario, and the table reflects the averages of the values.
Issue
Out of scope
ArrayList
orEagerLoadedDataList
should support SearchFilter syntax for filter/exclude #5911EagerLoadedList
can't filter or sort by fields on its relations #10874