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

Comparison Problem Default 'NULL' #2817

Closed
ndoulgeridis opened this issue Aug 18, 2017 · 7 comments
Closed

Comparison Problem Default 'NULL' #2817

ndoulgeridis opened this issue Aug 18, 2017 · 7 comments

Comments

@ndoulgeridis
Copy link

ndoulgeridis commented Aug 18, 2017

I am using

PHP                                  v7.1.7
MariaDB                              v10.2.7
doctrine/annotations                 v1.2.7    Docblock Annotations Parser
doctrine/cache                       v1.6.2    Caching library offering an object-oriented API for many cache    backends
doctrine/collections                 v1.3.0    Collections Abstraction library
doctrine/common                      v2.6.2    Common Library for Doctrine projects
doctrine/data-fixtures               v1.1.1    Data Fixtures for all Doctrine Object Managers
doctrine/dbal                        v2.5.13   Database Abstraction Layer
doctrine/doctrine-bundle             1.6.8     Symfony DoctrineBundle
doctrine/doctrine-cache-bundle       1.3.0     Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle    2.3.0     Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle  v1.1.0    Symfony DoctrineMigrationsBundle

When I run command:

php bin/console doctrine:schema:update --force

I get every time same queries run and of course with

php bin/console doctrine:schema:update --dump-sql 

I see every time the same SQL Queries (all of them ALTER).

So I have troubleshooted it a bit and found the following issue in:

vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php:210


$table1Columns = $table1->getColumns();
$table2Columns = $table2->getColumns();

More precisely the problem is on :

 vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php:438

  if ($properties1['default'] != $properties2['default'] ||
        // Null values need to be checked additionally as they tell whether to create or drop a default value.
        // null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
        (null === $properties1['default'] && null !== $properties2['default']) ||
        (null === $properties2['default'] && null !== $properties1['default'])
    ) {
        $changedProperties[] = 'default';
    }

The problem is that default null is different type. In table 1 is string "NULL" while in second table is a null type. Probably here need to cast or also check if property value is "NULL".

dbal-bug

Is this a known issue? Any workarounds how to fix this one? It should be a new issue due to PHP version or MySQL/MariaDB because it's impossible to be unspotted so far.

@ndoulgeridis ndoulgeridis changed the title Comaprison Problem Default 'NULL' Comparison Problem Default 'NULL' Aug 18, 2017
@Ocramius
Copy link
Member

Probably here need to cast or also check if property value is "NULL".

"NULL" is not NULL: one is a string, the other one is the absence of value.

Please check if this issue matches any of the following:

@ste93cry
Copy link
Contributor

After updating to MariaDB 10.2 on a CentOS server I'm experiencing the same problem. I just dumped the database from the server and imported it into MySQL on Windows and there is nothing to update according to the doctrine:schema:update --dump-sql command. However on the server all fields are marked as needing update when they shouldn't

@sagaraspl
Copy link

sagaraspl commented Aug 24, 2017

Hi @Crash21 and @Ocramius I am facing the same issue after updating to MariaDB 10.2.7

@belgattitude
Copy link
Contributor

Just found possible approaches to fix:

see my comment on doctrine/orm#6565

I'll publish a P/R soon

Seb

@belgattitude
Copy link
Contributor

Here's a P/R: #2825.

Feel free to test and comment.

@Majkl578
Copy link
Contributor

Majkl578 commented Dec 5, 2017

This is duplicate of doctrine/orm#6565 and should be fixed by #2825.

@github-actions
Copy link

github-actions bot commented Aug 3, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants