Reduce amount of mapping boilerplate #6894

Closed
opened 2026-01-22 15:40:52 +01:00 by admin · 1 comment
Owner

Originally created by @benblub on GitHub (Jan 7, 2022).

Bug Report

From https://www.doctrine-project.org/2021/05/24/orm2.9.html i tried reduce amount of mapping boilerplate. Remove type from attribute works for me but not nullable.

works

    #[ORM\Column]
    private string $title;

error

    #[ORM\Column]
    private ?string $title;

Output

Doctrine\DBAL\Exception\NotNullConstraintViolationException : An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null
 /app/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:116
 /app/vendor/doctrine/dbal/src/Connection.php:1768
..

works

    #[ORM\Column(nullable: true)]
    private ?string $title;
Q A
BC Break yes/no
Version 2.10.4

How to reproduce

run some unit test with provided entity data above.

Originally created by @benblub on GitHub (Jan 7, 2022). ### Bug Report From https://www.doctrine-project.org/2021/05/24/orm2.9.html i tried reduce amount of mapping boilerplate. Remove type from attribute works for me but not nullable. works ``` #[ORM\Column] private string $title; ``` error ```php #[ORM\Column] private ?string $title; ``` Output ```php Doctrine\DBAL\Exception\NotNullConstraintViolationException : An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null /app/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:116 /app/vendor/doctrine/dbal/src/Connection.php:1768 .. ``` works ```php #[ORM\Column(nullable: true)] private ?string $title; ``` | Q | A |------------ | ------ | BC Break | yes/no | Version | 2.10.4 #### How to reproduce run some unit test with provided entity data above.
admin closed this issue 2026-01-22 15:40:52 +01:00
Author
Owner

@derrabus commented on GitHub (Jan 8, 2022):

This is not a bug. Nullability is not inferred from the parameter types. You have to configure it explicitly.

@derrabus commented on GitHub (Jan 8, 2022): This is not a bug. Nullability is not inferred from the parameter types. You have to configure it explicitly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6894