Compare commits

..

No commits in common. "3736fbe0f6fd92b670f722a228a34b49670b7e48" and "d2bd6c2f588ffd8a41ed082e5725536558ba6c6a" have entirely different histories.

2 changed files with 5 additions and 8 deletions

View File

@ -302,12 +302,9 @@ trait EntityTrait {
}
#[Ignore]
public static function field($name, null|string|false $alias = Repository::DEFAULT_ALIAS) : EntityField
public static function field($name, null|string|bool $alias = Repository::DEFAULT_ALIAS) : EntityField
{
$default = ( $alias === false ? '' : Repository::DEFAULT_ALIAS ); # bw compatibility, to be deprecated
return new EntityField(static::class, $name, $alias ? Ulmus::repository(static::class)->adapter->adapter()->escapeIdentifier($alias, Adapter\AdapterInterface::IDENTIFIER_FIELD) : $default, Ulmus::resolveEntity(static::class));
return new EntityField(static::class, $name, $alias ? Ulmus::repository(static::class)->adapter->adapter()->escapeIdentifier($alias, Adapter\AdapterInterface::IDENTIFIER_FIELD) : ( $alias === false ? '' : Repository::DEFAULT_ALIAS ), Ulmus::resolveEntity(static::class));
}
#[Ignore]

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, null)->deleteOne()->rowCount;
return (bool) $this->wherePrimaryKey($value)->deleteOne()->rowCount;
}
public function destroy(object $entity) : bool
@ -599,7 +599,7 @@ class Repository
return $this;
}
public function wherePrimaryKey(mixed $value, null|string|bool $alias = self::DEFAULT_ALIAS) : self
public function wherePrimaryKey(mixed $value) : 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, false), $value);
return $this->where($this->entityClass::field($primaryKeyField[$pkField]->name ?? $pkField), $value);
}
public function withJoin(string|array $fields, array $options = []) : self