- Field mapper is now removed from Adapters and set into it's own object
- Added a PK to Column (IS)
This commit is contained in:
1 parent
9977a25cf5
commit
3c2ae86653
7 files changed
+168
-57
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Ulmus\Entity\InformationSchema;
|
||||
|
||||
use Notes\Common\ReflectedProperty;
|
||||
use Ulmus\Entity\Field\Datetime;
|
||||
|
||||
use Ulmus\{Attribute\Obj\Table};
|
||||
@@ -12,6 +13,9 @@ class Column
|
||||
{
|
||||
use \Ulmus\EntityTrait;
|
||||
|
||||
#[Field\Id]
|
||||
public ? id $srs_id;
|
||||
|
||||
#[Field(name: "TABLE_CATALOG", length: 512)]
|
||||
public string $tableCatalog;
|
||||
|
||||
@@ -78,4 +82,37 @@ class Column
|
||||
#[Field(name: "GENERATION_EXPRESSION", type: "longtext")]
|
||||
public ? string $generationExpression;
|
||||
|
||||
public function matchFieldDefinition(ReflectedProperty $definition) : bool
|
||||
{
|
||||
if ($this->nullable === $definition->allowsNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($definition->value)) {
|
||||
if ( $definition->value !== $this->defaultValue()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
elseif (! isset($definition->value)) {
|
||||
if ( ! $this->defaultValueIsNull() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function defaultValueIsNull() : bool
|
||||
{
|
||||
return $this->defaultValue() === null;
|
||||
}
|
||||
|
||||
protected function defaultValue() : mixed
|
||||
{
|
||||
if (is_numeric($this->default)) {
|
||||
return (int) $this->default;
|
||||
}
|
||||
|
||||
return $this->default;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user