- Migrated Entity's file into attributes

This commit is contained in:
Dave M. 2023-03-23 15:09:42 +00:00
parent fa8adcace1
commit 43880eb428
4 changed files with 77 additions and 191 deletions

View File

@ -4,121 +4,78 @@ namespace Ulmus\Entity\InformationSchema;
use Ulmus\Entity\Field\Datetime; use Ulmus\Entity\Field\Datetime;
/** use Ulmus\{Attribute\Obj\Table};
* @Table('name' => "columns", 'database' => "information_schema") use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
*/
#[Table(name: "columns", database: "information_schema")]
class Column class Column
{ {
use \Ulmus\EntityTrait; use \Ulmus\EntityTrait;
/** #[Field(name: "TABLE_CATALOG", length: 512)]
* @Field('name' => "TABLE_CATALOG", 'length' => 512)
*/
public string $tableCatalog; public string $tableCatalog;
/** #[Field(name: "TABLE_SCHEMA", length: 64)]
* @Field('name' => "TABLE_SCHEMA", 'length' => 64)
*/
public string $tableSchema; public string $tableSchema;
/** #[Field(name: "TABLE_NAME", length: 64)]
* @Field('name' => "TABLE_NAME", 'length' => 64)
*/
public string $tableName; public string $tableName;
/** #[Field(name: "COLUMN_NAME", length: 64, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "COLUMN_NAME", 'length' => 64, 'attributes' => [ 'primary_key' => true ])
*/
public string $name; public string $name;
/** #[Field(name: "ORDINAL_POSITION", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "ORDINAL_POSITION", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public int $ordinalPosition; public int $ordinalPosition;
/** #[Field(name: "COLUMN_DEFAULT", type: "longtext")]
* @Field('name' => "COLUMN_DEFAULT", 'type' => "longtext")
*/
public ? string $default; public ? string $default;
/** #[Field(name: "IS_NULLABLE", length: 3)]
* @Field('name' => "IS_NULLABLE", 'length' => 3)
*/
public string $nullable; public string $nullable;
/** #[Field(name: "DATA_TYPE", length: 64)]
* @Field('name' => "DATA_TYPE", 'length' => 64)
*/
public string $dataType; public string $dataType;
/** #[Field(name: "CHARACTER_MAXIMUM_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "CHARACTER_MAXIMUM_LENGTH", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? int $characterMaximumLength; public ? int $characterMaximumLength;
/** #[Field(name: "CHARACTER_OCTET_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "CHARACTER_OCTET_LENGTH", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? int $characterOctetLength; public ? int $characterOctetLength;
/** #[Field(name: "NUMERIC_PRECISION", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "NUMERIC_PRECISION", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? int $numericPrecision; public ? int $numericPrecision;
/** #[Field(name: "NUMERIC_SCALE", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "NUMERIC_SCALE", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? int $numericScale; public ? int $numericScale;
/** #[Field(name: "DATETIME_PRECISION", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "DATETIME_PRECISION", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? int $datetimePrecision; public ? int $datetimePrecision;
/** #[Field(name: "CHARACTER_SET_NAME", length: 32)]
* @Field('name' => "CHARACTER_SET_NAME", 'length' => 32)
*/
public ? string $characterSetName; public ? string $characterSetName;
/** #[Field(name: "COLLATION_NAME", length: 32)]
* @Field('name' => "COLLATION_NAME", 'length' => 32)
*/
public ? string $collationName; public ? string $collationName;
/** # #[Field(name: "COLLATION_TYPE", type: "longtext")]
* @Field('name' => "COLLATION_TYPE", 'type' => "longtext") # public string $type;
*/
public string $type;
/** #[Field(name: "COLUMN_KEY", length: 3)]
* @Field('name' => "COLUMN_KEY", 'length' => 3)
*/
public string $key; public string $key;
/** #[Field(name: "EXTRA", length: 30)]
* @Field('name' => "EXTRA", 'length' => 30)
*/
public string $extra; public string $extra;
/** #[Field(name: "PRIVILEGES", length: 80)]
* @Field('name' => "PRIVILEGES", 'length' => 80)
*/
public string $privileges; public string $privileges;
/** #[Field(name: "COLUMN_COMMENT", length: 1024)]
* @Field('name' => "COLUMN_COMMENT", 'length' => 1024)
*/
public string $comment; public string $comment;
/** #[Field(name: "IS_GENERATED", length: 6)]
* @Field('name' => "IS_GENERATED", 'length' => 6)
*/
public string $generated; public string $generated;
/** #[Field(name: "GENERATION_EXPRESSION", type: "longtext")]
* @Field('name' => "GENERATION_EXPRESSION", 'type' => "longtext")
*/
public ? string $generationExpression; public ? string $generationExpression;
} }

View File

@ -5,131 +5,84 @@ namespace Ulmus\Entity\InformationSchema;
use Ulmus\EntityCollection, use Ulmus\EntityCollection,
Ulmus\Entity\Field\Datetime; Ulmus\Entity\Field\Datetime;
/** use Ulmus\{Attribute\Obj\Table as TableObj};
* @Table('name' => "tables", 'database' => "information_schema") use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
*/
#[TableObj(name: "tables", database: "information_schema")]
class Table class Table
{ {
use \Ulmus\EntityTrait; use \Ulmus\EntityTrait;
/** #[Field(name: "TABLE_CATALOG", length: 512)]
* @Field('name' => "TABLE_CATALOG", 'length' => 512)
*/
public string $catalog; public string $catalog;
/** #[Field(name: "TABLE_SCHEMA", length: 64)]
* @Field('name' => "TABLE_SCHEMA", 'length' => 64)
*/
public string $schema; public string $schema;
/** #[Field(name: "TABLE_NAME", length: 64, attributes: [ 'primary_key' => true, ])]
* @Field('name' => "TABLE_NAME", 'length' => 64, 'attributes' => [ 'primary_key' => true ])
*/
public string $name; public string $name;
/** #[Field(name: "TABLE_TYPE", length: 64)]
* @Field('name' => "TABLE_TYPE", 'length' => 64)
*/
public string $type; public string $type;
/** #[Field(name: "ENGINE", length: 64)]
* @Field('name' => "ENGINE", 'length' => 64)
*/
public ? string $engine ; public ? string $engine ;
/** #[Field(name: "VERSION", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "VERSION", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $version; public ? string $version;
/** #[Field(name: "ROW_FORMAT", length: 10)]
* @Field('name' => "ROW_FORMAT", 'length' => 10)
*/
public ? string $rowFormat; public ? string $rowFormat;
/** #[Field(name: "TABLE_ROWS", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "TABLE_ROWS", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $rows; public ? string $rows;
/** #[Field(name: "AVG_ROW_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "AVG_ROW_LENGTH", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $averageRowLength; public ? string $averageRowLength;
/** #[Field(name: "DATA_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "DATA_LENGTH", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $dataLength; public ? string $dataLength;
/** #[Field(name: "MAX_DATA_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "MAX_DATA_LENGTH", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $maxDataLength; public ? string $maxDataLength;
/** #[Field(name: "INDEX_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "INDEX_LENGTH", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $indexLength; public ? string $indexLength;
/** #[Field(name: "DATA_FREE", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "DATA_FREE", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $dataFree; public ? string $dataFree;
/** #[Field(name: "AUTO_INCREMENT", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "AUTO_INCREMENT", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $autoIncrement; public ? string $autoIncrement;
/** #[Field(name: "CREATE_TIME")]
* @Field('name' => "CREATE_TIME")
*/
public ? Datetime $createTime; public ? Datetime $createTime;
/** #[Field(name: "UPDATE_TIME")]
* @Field('name' => "UPDATE_TIME")
*/
public ? Datetime $updateTime; public ? Datetime $updateTime;
/** #[Field(name: "CHECK_TIME")]
* @Field('name' => "CHECK_TIME")
*/
public ? Datetime $checkTime; public ? Datetime $checkTime;
/** #[Field(name: "TABLE_COLLATION", length: 32)]
* @Field('name' => "TABLE_COLLATION", 'length' => 32)
*/
public ? string $tableCollation; public ? string $tableCollation;
/** #[Field(name: "CHECKSUM", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "CHECKSUM", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? string $checksum; public ? string $checksum;
/** #[Field(name: "CREATE_OPTIONS", length: 2048)]
* @Field('name' => "CREATE_OPTIONS", 'length' => 2048)
*/
public ? string $createOptions; public ? string $createOptions;
/** #[Field(name: "TABLE_COMMENT", length: 2048)]
* @Field('name' => "TABLE_COMMENT", 'length' => 2048)
*/
public string $tableComment; public string $tableComment;
/** #[Field(name: "MAX_INDEX_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
* @Field('name' => "MAX_INDEX_LENGTH", 'type' => "bigint", 'length' => 21, 'attributes' => [ 'unsigned' => true ])
*/
public ? int $maxIndexLength; public ? int $maxIndexLength;
/** #[Field(name: "TEMPORARY", length: 1)]
* @Field('name' => "TEMPORARY", 'length' => 1)
*/
public ? string $temporary; public ? string $temporary;
/** #[Relation(type: "oneToMany", key: "name", foreignKey: [ Column::class, 'tableName' ], entity: Column::class)]
* @Relation('oneToMany', 'key' => 'name', 'foreignKey' => Column::field('tableName'), 'entity' => Column::class) #[Where('TABLE_SCHEMA', [ Column::class, 'tableSchema' ])]
* @Where('TABLE_SCHEMA', Column::field('tableSchema'))
*/
public EntityCollection $columns; public EntityCollection $columns;
} }

View File

@ -4,45 +4,32 @@ namespace Ulmus\Entity\Sqlite;
use Ulmus\EntityCollection; use Ulmus\EntityCollection;
/** use Ulmus\{Attribute\Obj\Table};
* @Table use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
*/
#[Table]
class Column class Column
{ {
use \Ulmus\EntityTrait; use \Ulmus\EntityTrait;
/** #[Id]
* @Id
*/
public int $cid; public int $cid;
/** #[Field]
* @Field
*/
public string $type; public string $type;
/** #[Field]
* @Field
*/
public string $name; public string $name;
/** #[Virtual]
* @Virtual
*/
public string $tableName; public string $tableName;
/** #[Field(name: "notnull")]
* @Field('name' => "notnull")
*/
public bool $notNull; public bool $notNull;
/** #[Field(name: "dflt_value")]
* @Field('name' => 'dflt_value')
*/
public ? string $defaultValue; public ? string $defaultValue;
/** #[Field(name: "pk")]
* @Field('name' => "pk")
*/
public bool $primaryKey; public bool $primaryKey;
} }

View File

@ -4,40 +4,29 @@ namespace Ulmus\Entity\Sqlite;
use Ulmus\EntityCollection; use Ulmus\EntityCollection;
/** use Ulmus\{Attribute\Obj\Table};
* @Table('name' => "sqlite_master") use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
*/
#[Table(name: "sqlite_master")]
class Schema class Schema
{ {
use \Ulmus\EntityTrait; use \Ulmus\EntityTrait;
/** #[Id]
* @Id
*/
public ? string $name; public ? string $name;
/** #[Field]
* @Field
*/
public ? string $type; public ? string $type;
/** #[Field(name: "tbl_name")]
* @Field('name' => 'tbl_name')
*/
public ? string $tableName; public ? string $tableName;
/** #[Field]
* @Field
*/
public ? int $rootpage; public ? int $rootpage;
/** #[Field]
* @Field
*/
public ? string $sql; public ? string $sql;
/** #[Relation("oneToMany", key: "tableName", foreignKey: "tableName", entity: "Schema")]
* @Relation('oneToMany', 'key' => 'tableName', 'foreignKey' => 'tableName', 'entity' => Schema::class)
*/
public EntityCollection $columns; public EntityCollection $columns;
} }