- Added a new Field Mapper to SQLs Adapters.

- Defined missing MySQL fields attributes
- WIP on lean-console's migration methods
This commit is contained in:
Dave Mc Nicoll committed 2024-10-21 18:12:24 +00:00
1 parent 5f4f23a8e4
commit 411992c7a8
17 files changed
+214 -8

No files matched your search

+9 -2
View File
@@ -84,11 +84,13 @@ class Column
public function matchFieldDefinition(ReflectedProperty $definition) : bool
{
if ($this->nullable === $definition->allowsNull()) {
$nullable = $this->nullable === 'YES';
if ($nullable !== $definition->allowsNull()) {
return false;
}
if (isset($definition->value)) {
if ( isset($definition->value) && $this->canHaveDefaultValue() ) {
if ( $definition->value !== $this->defaultValue()) {
return false;
}
@@ -115,4 +117,9 @@ class Column
return $this->default;
}
protected function canHaveDefaultValue() : bool
{
return true;
}
}
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace Ulmus\Entity\Mysql;
class Column extends \Ulmus\Entity\InformationSchema\Column
{
# TODO ! Handle FUNCTIONAL default value
protected function canHaveDefaultValue(): bool
{
return ! in_array(strtoupper($this->dataType), [
'BLOB', 'TINYBLOB', 'MEDIUMBLOB', 'LONGBLOB', 'JSON', 'TEXT', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'GEOMETRY'
]);
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace Ulmus\Entity\Mysql;
use Ulmus\EntityCollection,
Ulmus\Entity\Field\Datetime;
use Ulmus\{Attribute\Obj\Table as TableObj};
use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
#[TableObj(name: "tables", database: "information_schema")]
class Table extends \Ulmus\Entity\InformationSchema\Table
{
#[Relation(type: "oneToMany", key: "name", foreignKey: [ Column::class, 'tableName' ], entity: Column::class)]
#[Where('TABLE_SCHEMA', fieldValue: [ Column::class, 'tableSchema' ])]
public EntityCollection $columns;
}