Skip to content

Nullable property type does still not translate to nullable SQL column #8834

@fridde

Description

@fridde

Bug Report

Q A
BC Break no
Version 2.9.3

Summary

It seems like making a property type nullable like this

 #[ORM\Column]
    protected ?string $Location = null;

does not translate to the SQL column being nullable, contrary to what the docs say. It still has to be declared in the attribute as #[ORM\Column(nullable: true)].

How to reproduce

  1. Create an entity using attributes, for example
#[ORM\Table(name: "users")]
class User
{
    #[ORM\Id, ORM\Column, ORM\GeneratedValue]
    protected int $id;

    #[ORM\Column]
    protected ?string $Name = null;
}
  1. Set your mapping driver to "attribute".
  2. Create a migration with .\bin\console make:migration
  3. Inspect the created migration and see that within the up()-method you see [...] Name VARCHAR(255) NOT NULL [...]

Expected behavior

The last step should have contained [...] Name VARCHAR(255) DEFAULT NULL [...].

I think that @beberlei has been working on the implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions