-
Notifications
You must be signed in to change notification settings - Fork 47
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
Deduplicate load methods and assert only one row can be loaded if expected #846
Conversation
4b2c891
to
03a2a83
Compare
d9a17bd
to
09cf4fd
Compare
7d2d413
to
00551ee
Compare
1379862
to
bd7c6b3
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.
Quite a lot of changes, but LGTM
{ | ||
$load = $model->action('select'); | ||
$load->limit(1); | ||
$query->limit($id === self::ID_LOAD_ANY ? 1 : 2); |
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.
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.
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.
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 :)
no bc break
also add
Model::loadOne()
andModel::tryLoadOne()
methods