db icon indicating copy to clipboard operation
db copied to clipboard

Restore Query::one interface

Open darkdef opened this issue 5 months ago • 5 comments

Q A
Is bugfix? ✔️
New feature? ✔️
Breaks BC? ✔️/❌

darkdef avatar Jan 21 '24 15:01 darkdef

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.55%. Comparing base (749c3f3) to head (6e904c6).

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #798   +/-   ##
=========================================
  Coverage     99.55%   99.55%           
  Complexity     1277     1277           
=========================================
  Files            63       63           
  Lines          3120     3120           
=========================================
  Hits           3106     3106           
  Misses           14       14           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 21 '24 15:01 codecov[bot]

PR Summary

  • Modifications to the queryOne() method The queryOne() function, which can be found in AbstractCommand.php, CommandInterface.php, and CommandInterfaceProxy.php, underwent revisions that enable it to provide a more diverse set of results. This function formerly returned only arrays, but with this update, it can now return an array, an object, or even a null value. This improvement enhances the flexibility and coverage of the response types our system can deliver.

  • Improvements to the one() method Similar to the queryOne() modifications, we have updated the one() function in Query.php and QueryInterface.php to return either an array, an object, or a null value. Previously, the function was limited to just array results. This change broadens the scope of possible outputs, making our system more diverse and adaptable in responding to different query requirements.

what-the-diff[bot] avatar Jan 29 '24 19:01 what-the-diff[bot]

BatchQueryResult::$value and related methods also should have the type array|object|null

It's maybe incorrect for query with one column as scalar type.

darkdef avatar Jan 29 '24 19:01 darkdef

BatchQueryResult::$value and related methods also should have the type array|object|null

It's maybe incorrect for query with one column as scalar type.

This should be an array or object ($row) or array of arrays or objects ($rows) or null, but seems this is not related with the PR.

https://github.com/yiisoft/db/blob/ef81e8b7749525030dba95060b71a9f490fe2784/src/Query/BatchQueryResult.php#L103 https://github.com/yiisoft/db/blob/ef81e8b7749525030dba95060b71a9f490fe2784/src/Command/AbstractCommand.php#L425-L429

And after custom populate closure $rows can be changed to array of objects https://github.com/yiisoft/db/blob/ef81e8b7749525030dba95060b71a9f490fe2784/src/Query/BatchQueryResult.php#L108-L110

Tigrov avatar Jan 30 '24 04:01 Tigrov

Needs line to changelog

And fill UPGRADE.md too

vjik avatar Apr 07 '24 09:04 vjik