-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Improve IResult #56494
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
Improve IResult #56494
Conversation
provokateurin
left a comment
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.
I don't get the purpose of iterateNumeric and iterateAssociative if they just call the fetch methods. Developers will probably think that this optimizes memory consumption by not loading all results at once, but this is not the case as far as I understand from this code.
5e5e43e to
6f5952e
Compare
- fetch is replaced with fetchAssociative/fetchNumeric/fetchOne with
better type hinting
- Same with fetchAll
- And add iterateAssociative/iterateNumeric which are nicer to use than
a `while ($row = $result->fetch()) {}`
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
6f5952e to
2412fe2
Compare
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
2412fe2 to
2b61abd
Compare
ChristophWurst
left a comment
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.
Very nice
This will impact a lot of app code, so thanks for the rector rule 🙏
There should also be documentation for app devs including examples given the impact.
Is this really needed? This, same as with I'd be in favor of making a note, and once we have few things we want to deprecate, we do them in one organized released, instead of each release bringing a single change and you need to touch each place all the time |
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.
Why deprecate fetch / fetchAll? Instead, leave that with the default associative and remove the fetch mode parameter. Leave those code changes where no other result type is used, and refactor those instances where a PDO::FETCH_NUMERIC is used to the new exposed method.
Benefits: no Psalm errors, no backport conflicts, marginal change in the interface
But still add a note that the new methods are preferred. Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
I undeprecated fetch and fetchAll for now but we can't change the signature and behavior of these methods, otherwise it breaks a lot of stuff and we should avoid breaking changes. |
|
Documentation nextcloud/documentation#13866 |
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
|
What also would be cool is a Result interface that does not take the complete result array, but the pointer to the DB result resource. And then it can truly traverse memory-efficiently through the result set. Could be beneficial for network saturation in some cases as well, maybe? (Out of scope here) |
Best to review commit by commit. The last two are automated
Summary
Expose multiple methods from result from doctrine:
fetchAssociativefetchNumericfetchOnefetchAllAssociatefetchAllNumericfetchFirstColumniterateNumericiterateAssociateDeprecated
fetchandfetchAllA rector rule is also created to automate the transition nextcloud-libraries/rector#63
TODO
Checklist
3. to review, feature component)stable32)