jlorente/yii2-activerecord-inheritance

An extra query to the database on model.refresh()

dabkhazi opened this issue · 0 comments

Hello!
First of all thank you for your work!

I found a little issue. Trying explain it :)

If i refresh child model then i see that there are one extra query to parent table. Total 3 queries instead of 2.
I explored the source.

public function refresh() {
    $r = parent::refresh();
    return $this->_parent()->refresh() && $r;
}

$r = parent::refresh() do 2 queries:
query to child table and extra query to parent, Last query initiate by code:

public static function populateRecord($record, $row) {
parent::populateRecord($record, $row);

    _$record->_parent = $record->parent;_
}

Then
$this->_parent()->refresh() && $r do 1 query to parent

Hope you understand my explonation.