- Fixed an alias problem within deleteFromPk() method

This commit is contained in:
mcndave committed 2023-10-31 18:04:49 +00:00
1 parent 953fc35680
commit 667c1fe9ab
2 files changed
+8 -5

No files matched your search

+3 -3
View File
@@ -114,7 +114,7 @@ class Repository
throw new Exception\EntityPrimaryKeyUnknown("A primary key value has to be defined to delete an item.");
}
return (bool) $this->wherePrimaryKey($value)->deleteOne()->rowCount;
return (bool) $this->wherePrimaryKey($value, null)->deleteOne()->rowCount;
}
public function destroy(object $entity) : bool
@@ -599,7 +599,7 @@ class Repository
return $this;
}
public function wherePrimaryKey(mixed $value) : self
public function wherePrimaryKey(mixed $value, null|string|bool $alias = self::DEFAULT_ALIAS) : self
{
if ( null === $primaryKeyField = Ulmus::resolveEntity($this->entityClass)->getPrimaryKeyField() ) {
throw new Exception\EntityPrimaryKeyUnknown("Entity has no field containing attributes 'primary_key'");
@@ -607,7 +607,7 @@ class Repository
$pkField = key($primaryKeyField);
return $this->where($this->entityClass::field($primaryKeyField[$pkField]->name ?? $pkField), $value);
return $this->where($this->entityClass::field($primaryKeyField[$pkField]->name ?? $pkField, false), $value);
}
public function withJoin(string|array $fields, array $options = []) : self