- Added a new @PrimaryKey annotation to replace the too-specific property-wise @Id

This commit is contained in:
Dave Mc Nicoll committed 2022-11-11 13:57:29 +00:00
1 parent 0e8443b1c1
commit b20e537038
6 files changed
+33 -19

No files matched your search

+3 -3
View File
@@ -6,11 +6,11 @@ namespace Ulmus\Annotation\Property\Field;
* Since we need consistancy between the declaration of our ID and FK fields, it
* was decided to extend the Id class instead of Field for this case.
*/
class ForeignKey extends Id {
class ForeignKey extends PrimaryKey {
public function __construct()
public function __construct(? string $type = null, ? int $length = null)
{
parent::__construct();
parent::__construct($type, $length);
unset($this->nullable);
$this->attributes['primary_key'] = false;
+2 -4
View File
@@ -2,15 +2,13 @@
namespace Ulmus\Annotation\Property\Field;
class Id extends \Ulmus\Annotation\Property\Field {
class Id extends \Ulmus\Annotation\Property\Field\PrimaryKey {
public function __construct()
{
$this->nullable = false;
$this->attributes['unsigned'] = true;
$this->attributes['primary_key'] = true;
$this->attributes['auto_increment'] = true;
parent::__construct('bigint');
}
@@ -0,0 +1,15 @@
<?php
namespace Ulmus\Annotation\Property\Field;
class PrimaryKey extends \Ulmus\Annotation\Property\Field {
public function __construct(? string $type = null, ? int $length = null)
{
$this->nullable = false;
$this->attributes['primary_key'] = true;
parent::__construct($type, $length);
}
}