Skip to content

Split ActiveRecord model #412

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Split ActiveRecord model #412

wants to merge 4 commits into from

Conversation

Tigrov
Copy link
Member

@Tigrov Tigrov commented Apr 21, 2025

Q A
Is bugfix?
New feature? ✔️
Breaks BC? ✔️
Fixed issues #388, #358

Copy link

codecov bot commented Apr 21, 2025

Codecov Report

Attention: Patch coverage is 83.01158% with 44 lines in your changes missing coverage. Please review.

Project coverage is 88.40%. Comparing base (ec399f9) to head (3674162).

Files with missing lines Patch % Lines
src/Trait/ArrayAccessTrait.php 0.00% 17 Missing ⚠️
src/AbstractActiveRecord.php 88.11% 12 Missing ⚠️
src/Trait/MagicPropertiesTrait.php 80.00% 6 Missing ⚠️
src/ActiveQuery.php 86.84% 5 Missing ⚠️
src/Trait/CustomTableNameTrait.php 0.00% 2 Missing ⚠️
src/ActiveRelationTrait.php 95.00% 1 Missing ⚠️
src/Trait/ArrayIteratorTrait.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #412      +/-   ##
============================================
- Coverage     88.65%   88.40%   -0.25%     
- Complexity      567      571       +4     
============================================
  Files            16       18       +2     
  Lines          1357     1371      +14     
============================================
+ Hits           1203     1212       +9     
- Misses          154      159       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidConfigException;

interface ActiveRecordModelInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need description of the interface. What is it for?

From what I see now:

  1. It holds DB connection.
  2. It holds metadata such as table name.
  3. It holds data in terms of property-value pairs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I don't see a clear separation/purpose between ActiveRecordModelInterface and ActiveRecordInterface. They are still very much inter-dependent, but moved into two interfaces.

*
* @return bool Whether the two active records refer to the same row in the same database table.
*/
public function equals(self $record): bool;
public function equals(ActiveRecordModelInterface $record): bool;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look correct. Either the method should be moved to ActiveRecordModelInterface or ActiveRecordInterface should be used here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActiveRecordInterface should be here and one more method modelEquals(ActiveRecordModelInterface $model) should be added.

use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;

/**
* This interface is used by {@see ActiveRecordModelInterface}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a proper description about what is the purpose of this interface and what's the relation with ActiveRecordModelInterface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants