Skip to content

Bug with server_version for MariaDB >10.2.7 #2985

@tristanbes

Description

@tristanbes
Contributor

Hello,

I think there is a problem when providing the server_version parameter.

when having a server_version set to 10.2.12, the bug discussed here is still present. (it generates endless migrations diff)

When removing the server_version parameter, it works as excepted.

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                server_version: "%database_server_version%"  // << resolves to 10.2.12

We also tried

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                server_version: 10.2.12 

Could it be that the excepted version is something else than 10.2.x ?

Activity

lcobucci

lcobucci commented on Jan 22, 2018

@lcobucci
Member

@tristanbes could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing.

tristanbes

tristanbes commented on Jan 22, 2018

@tristanbes
ContributorAuthor

ping @Kocal

Kocal

Kocal commented on Jan 22, 2018

@Kocal

Hey!

I re-used the testing project made here by @Bukashk0zzz, in 3 different versions:

server_version Travis GitHub
'10.2.12' (quotes) Failing Branch
10.2.12 (no quotes) Passing Branch
No server_version (commented) Failed Branch
Ocramius

Ocramius commented on Jan 24, 2018

@Ocramius
Member
Kocal

Kocal commented on Jan 28, 2018

@Kocal

Hey,

I isolated the project from Symfony and this is what I found:

serverVersion Travis GitHub
'10.2.12' (quotes) Failing Branch
10.2.12 (no quotes) Failing Branch
No serverVersion (commented) Passing Branch

It seems that outside Symfony, 3rd and 4nd versions are failing ... 🤔

EDIT: I forgotten to use doctrine/dbal:dev-master, now all versions are working 😨

EDIT 2: I renamed server_version to serverVersion (thanks @nick4fake). Now the first and second tests are failing, and it's not really coherent with previous results inside Symfony context... 😞

tristanbes

tristanbes commented on Jan 28, 2018

@tristanbes
ContributorAuthor
Kocal

Kocal commented on Jan 28, 2018

@Kocal

Oh, I forgotten it again ... thx 👍

nick4fake

nick4fake commented on Jan 28, 2018

@nick4fake

Still an issue with doctrine/dbal master.

Setting server_version to any version returns update bug back

Kocal

Kocal commented on Jan 28, 2018

@Kocal

Inside or oustide Symfony context?

nick4fake

nick4fake commented on Jan 28, 2018

@nick4fake

Inside Symfony context with bitnami/mariadb:10.2.12-r0 image. Commenting out version helps, but this is not something we can do (as doctrine tries to connect to db on cache:clear)

nick4fake

nick4fake commented on Jan 28, 2018

@nick4fake

@Kocal BTW, it seems you are using "server_version" parameter in your test, but isn't the correct naming serverVersion?

Doctrine bundle in symfony translates server_version to serverVersion.

Kocal

Kocal commented on Jan 28, 2018

@Kocal

Oh, you are right, I wasn't aware about this.
I'm working on it 😄

Kocal

Kocal commented on Jan 28, 2018

@Kocal

Updated, now it's when I don't specify serverVersion that everything works

26 remaining items

violuke

violuke commented on Apr 16, 2018

@violuke

For me on doctrine v2.6.1 (with Symfony) we need a server_version of 10.2.14-mariadb (so the mariadb bit at the end, not the beginning. I hope this helps others.

tristanbes

tristanbes commented on Apr 16, 2018

@tristanbes
ContributorAuthor

well it doesn't seem to make a difference since the condition is
$mariadb = false !== stripos($version, 'mariadb');

So as soon as mariadb is detected, it should be ok ?

violuke

violuke commented on Apr 16, 2018

@violuke

When I use it with mariadb- at the start, I get the following, but with it at the end it seems to be ok.

Invalid  platform version "mariadb-10.2.14" specified. The platform version has  to be specified in the format:  "<major_version>.<minor_version>.<patch_version>".

in DBALException.php (line 80)
at DBALException::invalidPlatformVersionSpecified('mariadb-10.2.14', '<major_version>.<minor_version>.<patch_version>')in AbstractMySQLDriver.php (line 132)
at AbstractMySQLDriver->createDatabasePlatformForVersion('mariadb-10.2.14')in Connection.php (line 399)
at Connection->detectDatabasePlatform()in Connection.php (line 338)
at Connection->getDatabasePlatform()in ConnectionFactory.php (line 93)
at ConnectionFactory->getDatabasePlatform(object(Connection))in ConnectionFactory.php (line 63)

Thanks

tristanbes

tristanbes commented on Apr 16, 2018

@tristanbes
ContributorAuthor

and are you sure you are using doctrine/dbal >=2.7 @violuke

What does tell you composer show doctrine/dbal ?

violuke

violuke commented on Apr 17, 2018

@violuke

@tristanbes, no I'm using 2.6.1 of doctrine/orm and 2.6.3 of doctrine/dbal. I said I was on 2.6 originally. Does this change from 2.6 to 2.7?

name     : doctrine/dbal
descrip. : Database Abstraction Layer
keywords : database, dbal, persistence, queryobject
versions : * v2.6.3
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
source   : [git] https://github.com/doctrine/dbal.git e3eed9b1facbb0ced3a0995244843a189e7d1b13
dist     : [zip] https://api.github.com/repos/doctrine/dbal/zipball/e3eed9b1facbb0ced3a0995244843a189e7d1b13 e3eed9b1facbb0ced3a0995244843a189e7d1b13
names    : doctrine/dbal

autoload
psr-0
Doctrine\DBAL\ => lib/

requires
doctrine/common ^2.7.1
ext-pdo *
php ^7.1

requires (dev)
phpunit/phpunit ^5.4.6
phpunit/phpunit-mock-objects !=3.2.4,!=3.2.5
symfony/console 2.*||^3.0

suggests
symfony/console For helpful console commands such as SQL execution and import of files.

Thanks

tristanbes

tristanbes commented on Apr 17, 2018

@tristanbes
ContributorAuthor

Yes, MariaDB is only supported with dbal >= 2.7

mrtnzagustin

mrtnzagustin commented on Mar 12, 2020

@mrtnzagustin

I have problems with endless migration files when dbal is not detecting nulls. The problem is with doctrine/dbal 2.9.2 and mariadb 1.3.x and 1.4.x. Tried everything

w3sami

w3sami commented on Apr 22, 2020

@w3sami

I'm too still (for years now) having the same issue. current versions
dbal 2.10.2
10.4.12-mariadb
symfony 5

mrtnzagustin

mrtnzagustin commented on Apr 22, 2020

@mrtnzagustin

@w3sami we make a deep analysis and we were having problems with "default" values sintax in our annotations, make sure to double check that!

w3sami

w3sami commented on Apr 22, 2020

@w3sami

Hi, thanks for the reply. I'm not using any default values. Probles are in every field, even in relations eg.
/**
* @Orm\OneToOne(targetEntity="App\Entity\Menu", inversedBy="Page")
* @Orm\JoinColumn(name="menu_id", referencedColumnName="id", unique=true, onDelete="CASCADE")
*/
private $Menu;
for this i always get
ALTER TABLE page CHANGE menu_id menu_id INT DEFAULT NULL
due to the NULL != 'NULL' bug.
Are you saying, you somehow went around the problem by adding default values to your entity annotations?

mrtnzagustin

mrtnzagustin commented on Apr 22, 2020

@mrtnzagustin

Exactly, we had problems with default '0' vs 0 in booleans for example, and we focus to explicity add defaults values until fix the issue. It's a workaround, but it better than having buggy migrations outputs.

w3sami

w3sami commented on Apr 22, 2020

@w3sami

yes, sadly it does not help for the join column as the option is to add nullable=flase, which yields the same results, as it is the default already.
BUT! I actually ran the suggested var_dump(get_class($connection->getDriver()), get_class($connection->getDatabasePlatform())); from above, and found out, that it tried to use mysql5.7, even tho I had setted the config. The problem was, that in the default symfony configs, the server version is in the .env file! I cleared that up, and now it works just fine :)

github-actions

github-actions commented on Jul 29, 2022

@github-actions

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.

locked as resolved and limited conversation to collaborators on Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Majkl578@Ocramius@lcobucci@tristanbes@nick4fake

        Issue actions

          Bug with server_version for MariaDB >10.2.7 · Issue #2985 · doctrine/dbal