From 47aa384c4b3dc5ef6b8830a87a2efc562535fb34 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Thu, 26 Nov 2026 18:35:02 +0000 Subject: [PATCH] - Renamed update() to queryUpdate() --- src/Common/EntityResolver.php | 9 ++++++--- src/Repository.php | 6 +++++- src/Repository/QueryBuildingTrait.php | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Common/EntityResolver.php b/src/Common/EntityResolver.php index ba16930..37a8fb0 100644 --- a/src/Common/EntityResolver.php +++ b/src/Common/EntityResolver.php @@ -27,7 +27,7 @@ class EntityResolver { public string $entityClass; - public ReflectedClass $reflectedClass; + public readonly ReflectedClass $reflectedClass; protected array $fieldList = []; @@ -129,6 +129,11 @@ class EntityResolver { return $this->reflectedClass->getProperties(true)[$name]->getTypes()[0]->type ?? false; } + public function searchPropertyAttributeList(array|string $className, bool $deepSearch = true) : array + { + return $this->reflectedClass->getPropertyAttributeListFromClassname($className, $deepSearch, false); + } + public function searchFieldAnnotation(string $field, array|object|string $annotationType, bool $caseSensitive = true) : ? object { return $this->searchFieldAnnotationList($field, $annotationType, $caseSensitive)[0] ?? null; @@ -136,8 +141,6 @@ class EntityResolver { public function searchFieldAnnotationList(string $field, array|object|string $attributeType, bool $caseSensitive = true) : false|array { - $list = []; - $properties = $this->reflectedClass->getProperties(true); $search = $caseSensitive ? $properties : array_change_key_case($properties, \CASE_LOWER); diff --git a/src/Repository.php b/src/Repository.php index 084330a..ecb9e1e 100644 --- a/src/Repository.php +++ b/src/Repository.php @@ -369,7 +369,11 @@ class Repository implements RepositoryInterface $dataset = $this->generateDatasetDiff($entity, $oldValues); foreach($dataset as $field => $value) { - if ( false === ( $this->entityResolver->searchFieldAnnotation($field, Field::class, false)->readonly ?? false ) ) { + $readonly = $this->entityResolver->searchFieldAnnotation($field, Field::class, false)->readonly ?? + $this->entityResolver->searchField($field)->getAttribute(Field::class)->object->readonly ?? + false; + + if ( ! $readonly ) { $intersect[$field] = $field; } } diff --git a/src/Repository/QueryBuildingTrait.php b/src/Repository/QueryBuildingTrait.php index 878f910..053fa85 100644 --- a/src/Repository/QueryBuildingTrait.php +++ b/src/Repository/QueryBuildingTrait.php @@ -43,7 +43,7 @@ trait QueryBuildingTrait return $this; } - public function update(string $table, string $alias, ? string $schema) : self + public function queryUpdate(string $table, string $alias, ? string $schema) : self { $this->queryBuilder->update($this->escapeTable($table), $alias ? $this->escapeIdentifier($alias) : null, $this->escapedDatabase(), $schema); @@ -210,7 +210,7 @@ trait QueryBuildingTrait protected function updateSqlQuery(array $dataset) : self { if ( null === $this->queryBuilder->getFragment(Query\Update::class) ) { - $this->update($this->entityResolver->tableName(), $this->alias, $this->entityResolver->schemaName()); + $this->queryUpdate($this->entityResolver->tableName(), $this->alias, $this->entityResolver->schemaName()); } $this->set($dataset);