0 votes

Hello,

I'm facing a issue/problem. I have a working project with Symfony 4 (using doctrine2 annotations) with a relative massive amount of entities. I'm trying to import and export the entities after some changes. The problem is that by default doctrine sets "nullable=false" as default if nullable is not defined.

Doctrine 2.6 Documentation

Actually in my Entities I didn't set nullable so the spected behavior is to Skipper detects all the fields as NOT NULL. But this doesn't happen and also when I export all the entities again everything changes to nullable=true.

Is this a issue? or there's a workaround for this instead of setting all fields to NOT NULL manually?

Thanks.

asked in Feature Request by (150 points)

Hello,

this is definitely weird behavior. The skipper should not modify nullable from false to true.

But it's strange that you're facing such basic issue and no one else reported that.

Can you please send me part of your project where is this behavior reproducible?

To [email protected]

Thanks

Oh, wait. I just noticed something you wrote.

"The problem is that by default doctrine sets "nullable=false" as default if nullable is not defined."

and

"so the spected behavior is to Skipper detects all the fields as NOT NULL"

In case by "spected" you mean "Expected", then this is not true.

"NOT NULL==true" means "nullable=false". It's reverted ;-). It's means not(nullable).

So, if Skipper doesn't check "NOT NULL" after import, then this means, that "nullable=false" is correctly configured.

But it's strange if import&export caused that some values are changed. This shouldn't happen.

So if the problem is in something else, please send me the test project and I will check it.

Thanks

Exacty, I think it's quite basic thing.

You can reply the issue with this sample Tag.php entity:

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Class Tag
 * @ORM\Entity()
 */
class Tag
{

    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $name;

}

As you can see name doesn't have nullable=false, but when imported:

enter image description here

It should be parsed as NOT NULL by default.

It's very strange.

All our unit tests behave that missing "nullable" means nullable=true.

So Skipper behaves like this all the time from 2012, so I have to check Doctrine2 documentation history if there weren't any change in this.

We will inspect it and let you know.

A quick question about your checkmarks. You have some special skin in your Linux that checkboxes are wrongly displayed? What OS and skin are you using so we can check that too.

Thanks

It seems that this behavior was changed somewhere between 2.5 and 2.6 version.

As you can see in the documentation

In 2.5:
"nullable: Determines if NULL values allowed for this column."
https://www.doctrine-project.org/projects/doctrine-orm/en/2.5/reference/annotations-reference.html#annotations-reference

In 2.6
"nullable: Determines if NULL values allowed for this column. If not specified, default value is false."
https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/annotations-reference.html#reference

I believe that originally this behavior was reversed, because in 2.5 documentation, you can also found, that for @JoinColumns, there is still nullable=true when not filled.

"nullable: Determine whether the related entity is required, or if null is an allowed state for the relation. Defaults to true."

It's a really tricky. But it's not a big deal, we will change the behavior for that. I will let you know with the update.

Thank you for your time,

As far as I know Doctrine 2.6 Documentation says:

nullable: Determines if NULL values allowed for this column. If not specified, default value is false.

So, nullable is not set it will be set as false by default. So it should be NOT NULL. As you said: NOT NULL = nullable=false

If I check the NOT NULL field it exports as expected :)

/**
 * @ORM\Column(type="string", length=255, nullable=false)
 */
private $name;

About the weird check boxes I'm using Ubuntu 16.04 with a custom theme so it's quite normal. I also tested on Windows 10 and I get the same output. No worries.

You're right. 2.6 documentation explicitly set that not specified=> nullable=false.

But 2.5 doesn't contain it. And also, on other places (@JoinColumn), where nullable is used, is still "missing = nullable=true". It's pretty strange, but we update it to comply with the latest Doctrine version.

I will let you know today/tomorrow.

Good catch!

I don't know if this should be somewhere in the configuration for some other users with other Doctrine versions. Maybe a selector with different Doctrine versions could be a good idea.

I'll be waiting! is a huge headache to set this to all the fields on my database and it's kind of hard to remember if each field should be required or not.

Thank you!

1 Answer

0 votes
Best answer

Hello,

new beta with updated nullable logic is released.

You can download it here: https://support.skipper18.com/402/downloads-skipper-beta

Please let me know if all works as expected.

Ludek

answered by Skipper developer (134k points)
selected by

PS: We also updated checkboxes drawing logic for Linux. Hope it will help also for your case.

Everything is working now!
Also the check boxes are fixed. I will keep testing it.

Thank you!