Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When property type is nullable, nullable attribute is not true #8843

Closed
Rixafy opened this issue Jul 14, 2021 · 3 comments
Closed

When property type is nullable, nullable attribute is not true #8843

Rixafy opened this issue Jul 14, 2021 · 3 comments

Comments

@Rixafy
Copy link

Rixafy commented Jul 14, 2021

Bug Report

Q A
PHP Version 8.0.3
ORM Version 2.9.3
Annotations Version 2.13.1
Migrations Version 2.3.4

Hello, I tried to use PHP type mapping and I also removed nullable property since it says it will be automatically determined when variable type is nullable as said in https://www.doctrine-project.org/projects/doctrine-orm/en/2.9/reference/basic-mapping.html#php-types-mapping

The problem occurred when I removed nullable column attributes, I tried to create migration with diff command (should be empty) but there is ~20 SQL statements for changing nullable columns to non-null, even when their type is nullable (for instance ?string), cache was clear when new migrations was generated.

@Rixafy
Copy link
Author

Rixafy commented Jul 14, 2021

Ah, it's because someone didn't want it, but I don't understand why #8732

Why isn't variable nullability preferred? If someone want to have different nullability in DB and in code he can declare it with nullable argument.

It was already in 2.9, and it's not big BC break, since it was in 2.9 (removed in 2.9.2), and if someone has nullable variable but column is non-null, why would be variable nullable, what's the use-case for this?
It seems like it will only help detect potential problems as mentioned by @Slamdunk in #8732 (comment)

Those people that had nullable types but didn't want them in DB will notice when they create next migration, and if it's somehow overlooked (worst case, developer should always check migration), it's not really a big issue, making column nullable.

@fridde
Copy link
Contributor

fridde commented Jul 26, 2021

Just a comment:

and it's not big BC break

Maybe not a big, but it is a BC break. Thus if we don't want to violate the pretty important rules of semantic versioning (and I really wouldn't want that) we'll have to wait for 3.0.

Check out this comment

@beberlei
Copy link
Member

beberlei commented Aug 4, 2021

Duplicate of previous discussions

@beberlei beberlei closed this as completed Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants