Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Enh #564: Clarify `$relations` parameter type in `JoinWith::__construct()` from `array<string|Closure>` to
`array<string|callable(ActiveQueryInterface):void>` (@vjik)
- Bug #561: Fix `ActiveRecordInterface::upsert()` with `$updateProperties = false` (@Tigrov)
- Bug #550: Relation query should be created by related class, not primary model class (@batyrmastyr)

## 1.0.2 March 11, 2026

Expand Down
4 changes: 3 additions & 1 deletion src/AbstractActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@

public function createQuery(ActiveRecordInterface|string|null $modelClass = null): ActiveQueryInterface
{
return static::query($modelClass ?? $this);
$modelClass ??= $this;

return $modelClass::query($modelClass);
}

public function delete(): int
Expand All @@ -81,7 +83,7 @@

public function equals(ActiveRecordInterface $record): bool
{
if ($this->isNew() || $record->isNew()) {

Check warning on line 86 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "LogicalOr": @@ @@ public function equals(ActiveRecordInterface $record): bool { - if ($this->isNew() || $record->isNew()) { + if ($this->isNew() && $record->isNew()) { return false; }
return false;
}

Expand Down Expand Up @@ -148,7 +150,7 @@
return match (count($keys)) {
1 => $this->oldValues[$keys[0]] ?? null,
0 => throw new LogicException(
static::class . ' does not have a primary key. You should either define a primary key for '

Check warning on line 153 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ 1 => $this->oldValues[$keys[0]] ?? null, 0 => throw new LogicException( static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + . $this->tableName(), ), default => throw new LogicException( static::class . ' has multiple primary keys. Use primaryKeyOldValues() method instead.',

Check warning on line 153 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "Concat": @@ @@ return match (count($keys)) { 1 => $this->oldValues[$keys[0]] ?? null, 0 => throw new LogicException( - static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + static::class . ' does not have a primary key. You should either define a primary key for ' . ' table or override the primaryKey() method.' . $this->tableName(), ), default => throw new LogicException( static::class . ' has multiple primary keys. Use primaryKeyOldValues() method instead.',

Check warning on line 153 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ return match (count($keys)) { 1 => $this->oldValues[$keys[0]] ?? null, 0 => throw new LogicException( - static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + static::class . ' does not have a primary key. You should either define a primary key for ' . ' table or override the primaryKey() method.', ), default => throw new LogicException( static::class . ' has multiple primary keys. Use primaryKeyOldValues() method instead.',
. $this->tableName() . ' table or override the primaryKey() method.',
),
default => throw new LogicException(
Expand All @@ -163,7 +165,7 @@

if (empty($keys)) {
throw new LogicException(
static::class . ' does not have a primary key. You should either define a primary key for '

Check warning on line 168 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ if (empty($keys)) { throw new LogicException( static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + . $this->tableName(), ); }

Check warning on line 168 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "Concat": @@ @@ if (empty($keys)) { throw new LogicException( - static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + static::class . ' does not have a primary key. You should either define a primary key for ' . ' table or override the primaryKey() method.' . $this->tableName(), ); }

Check warning on line 168 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ if (empty($keys)) { throw new LogicException( - static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + static::class . ' does not have a primary key. You should either define a primary key for ' . ' table or override the primaryKey() method.', ); }
. $this->tableName() . ' table or override the primaryKey() method.',
);
}
Expand All @@ -188,7 +190,7 @@
return match (count($keys)) {
1 => $this->get($keys[0]),
0 => throw new LogicException(
static::class . ' does not have a primary key. You should either define a primary key for '

Check warning on line 193 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ 1 => $this->get($keys[0]), 0 => throw new LogicException( static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + . $this->tableName(), ), default => throw new LogicException( static::class . ' has multiple primary keys. Use primaryKeyValues() method instead.',

Check warning on line 193 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "Concat": @@ @@ return match (count($keys)) { 1 => $this->get($keys[0]), 0 => throw new LogicException( - static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + static::class . ' does not have a primary key. You should either define a primary key for ' . ' table or override the primaryKey() method.' . $this->tableName(), ), default => throw new LogicException( static::class . ' has multiple primary keys. Use primaryKeyValues() method instead.',

Check warning on line 193 in src/AbstractActiveRecord.php

View workflow job for this annotation

GitHub Actions / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ return match (count($keys)) { 1 => $this->get($keys[0]), 0 => throw new LogicException( - static::class . ' does not have a primary key. You should either define a primary key for ' - . $this->tableName() . ' table or override the primaryKey() method.', + static::class . ' does not have a primary key. You should either define a primary key for ' . ' table or override the primaryKey() method.', ), default => throw new LogicException( static::class . ' has multiple primary keys. Use primaryKeyValues() method instead.',
. $this->tableName() . ' table or override the primaryKey() method.',
),
default => throw new LogicException(
Expand Down
2 changes: 1 addition & 1 deletion tests/ActiveQueryFindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public function testFindLazy(): void
$customer = $customerQuery->findByPk(2);
$this->assertFalse($customer->isRelationPopulated('orders'));

$orders = $customer->getOrdersQuery()->where(['id' => 3])->all();
$orders = $customer->getOrdersQuery()->andWhere(['id' => 3])->all();
$this->assertFalse($customer->isRelationPopulated('orders'));
$this->assertCount(0, $customer->relatedRecords());
$this->assertCount(1, $orders);
Expand Down
Loading