yiisoft / db

Yii Database Library
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
134 stars 35 forks source link

Restore Query::one interface #798

Closed darkdef closed 2 months ago

darkdef commented 10 months ago
Q A
Is bugfix? ✔️
New feature? ✔️
Breaks BC? ✔️/❌
codecov[bot] commented 10 months ago

Codecov Report

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

Project coverage is 99.61%. Comparing base (6a8ceea) to head (b6db838).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #798 +/- ## ========================================= Coverage 99.61% 99.61% Complexity 1372 1372 ========================================= Files 74 74 Lines 3362 3362 ========================================= Hits 3349 3349 Misses 13 13 ```

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

what-the-diff[bot] commented 9 months ago

PR Summary

darkdef commented 9 months ago

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.

Tigrov commented 9 months ago

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

vjik commented 7 months ago

Needs line to changelog

And fill UPGRADE.md too

Tigrov commented 3 months ago

Do we need also fix type of CommandInterface::queryAll()?

Currently it looks excessive and needs refactoring DbArrayHelper for supporting objects but it looks redundant.