Deduplicate load methods and assert only one row can be loaded if expected#846
Merged
DarkSide666 merged 10 commits intodevelopfrom Apr 7, 2021
Merged
Deduplicate load methods and assert only one row can be loaded if expected#846DarkSide666 merged 10 commits intodevelopfrom
DarkSide666 merged 10 commits intodevelopfrom
Conversation
4b2c891 to
03a2a83
Compare
d9a17bd to
09cf4fd
Compare
7d2d413 to
00551ee
Compare
1379862 to
bd7c6b3
Compare
DarkSide666
approved these changes
Apr 7, 2021
Member
DarkSide666
left a comment
There was a problem hiding this comment.
Quite a lot of changes, but LGTM
| { | ||
| $load = $model->action('select'); | ||
| $load->limit(1); | ||
| $query->limit($id === self::ID_LOAD_ANY ? 1 : 2); |
Member
There was a problem hiding this comment.
smart move with limit(2) :)
I think that will not be very bad for performance if it tries to select 2 records instead of one.
Only question is - what if table will actually have only one record? Then it will not be able to detect issue here.
Member
Author
There was a problem hiding this comment.
yes, performance should be fine
Only question is - what if table will actually have only one record? Then it will not be able to detect issue here.
that is expected and not only if table have not one record, but also if conditions match only one record :)
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.
no bc break
also add
Model::loadOne()andModel::tryLoadOne()methods