- Work done on many-to-many relations - code must still be refactored out of the EntityTrait.

- Fixed Entity::field("propertyname") function to look for name into @Field() annotation and returns it if it exists.
- A lot of bug fixes made into SQL fragments.
This commit is contained in:
Dave Mc Nicoll committed 2020-04-09 09:50:09 -04:00
1 parent 6e84fc7195
commit c64c7778bd
20 files changed
+220 -105

No files matched your search

+8 -8
View File
@@ -2,7 +2,8 @@
namespace Ulmus\Common;
use Ulmus\Ulmus;
use Ulmus\Ulmus,
Ulmus\Annotation\Property\Field;
class EntityField
{
@@ -14,20 +15,19 @@ class EntityField
protected EntityResolver $entityResolver;
public function __construct(string $entityClass, string $name, string $alias)
public function __construct(string $entityClass, string $name, string $alias, EntityResolver $resolver)
{
$this->entityClass = $entityClass;
$this->name = $name;
$this->alias = $alias;
$this->entityResolver = Ulmus::resolveEntity(static::class);
}
$this->entityResolver = $resolver;
}
public function name($useAlias = true) : string
{
# Must use REFLECTION before throwing this value.
# Should first check if it's a relation field, and if it is,
# it's real key must be returned (PK usually)
return $useAlias ? "{$this->alias}.\"{$this->name}\"" : "\"{$this->name}\"";
$name = $this->entityResolver->searchFieldAnnotation($this->name, new Field() )->name ?? $this->name;
return $useAlias ? "{$this->alias}.\"{$name}\"" : "\"{$name}\"";
}
public static function isScalarType($type) : bool