Skip to content

Serial type of field in entities ignores nullable: true annotation #156

@lotyp

Description

@lotyp

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

I'm trying to add a SERIAL field as incremental_id. When creating a table, if I set nullable: true, it seems that this annotation is ignored.

Example:

#[Entity(repository: CheckoutRepository::class)]
class Checkout
{
    #[Column(type: 'serial', nullable: true, unique: true)]
    public ?int $incrementalId = null;

    #[Column(type: 'uuid', primary: true, typecast: [CheckoutId::class, 'castValue'], unique: true)]
    private CheckoutId $id;

    // ...

When migrations are generated, in code I see:

$this->table('checkouts')
->addColumn('id', 'uuid', ['nullable' => false, 'defaultValue' => null, 'unique' => true])
->addColumn('incremental_id', 'serial', ['nullable' => false, 'defaultValue' => null])

Version

PHP 8.2

cycle/migrations v4.2.3
cycle/annotated: v3.4.0
cycle/database: v2.7.1
cycle/orm v2.6.1

Initial PR, that added support for SERIAL:

https://github.com/cycle/database/pull/106/files

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions