Dbal: PostgreSQL 10: sequence definition failed

Created on 11 May 2018  路  5Comments  路  Source: doctrine/dbal

Bug Report

| Q | A
|------------ | ------
| BC Break | no
| Version | 2.7.1

Summary

Commad orm:schema-tool:update run invalid SQLSELECT min_value, increment_by FROM XXX after upgrade from PostgreSQL 9.6 to 10.3.

Current behavior

There is a invalid SQL query for PostgreSQL 10+ at PostgreSqlSchemaManager.php . In PostgreSQL 10+ is a new table for sequences called "pg_sequences" which contains required informations.

How to reproduce

Install PostgreSQL 10+ and run command orm:schema-tool:update or simply call method \Doctrine\DBAL\Schema\PostgreSqlSchemaManager::_getPortableSequenceDefinition() with some sequence name.

Expected behavior

PostgreSQLSchemaManager should call different SQL query for PostgreSQL 10+.

Working solution is written here https://stackoverflow.com/a/47980943.

Bug Invalid

Most helpful comment

You're right. Platform class is for PostgreSQL 9.4 Doctrine\DBAL\Platforms\PostgreSQL94Platform. Command is OK when i switch to Doctrine\DBAL\Platforms\PostgreSQL100Platform.
Thank you!

All 5 comments

Are you sure you are correctly using PostgreSQL 10 platform and not 9.6?
In case of PostgreSQL 10, list of all sequences with their increment_by and min_value is known beforehand so the query should not be executed at all (that code path should be skipped).

Hi Michal, yes i am pretty sure.

~ psql --version
psql (PostgreSQL) 10.3 (Ubuntu 10.3-1)

Here is issue with same bug #2868 which i found approx. 10 minutes before your answer. So this issue is duplicated issue. Sorry for this.

That is version of your PostgreSQL server, but is your DBAL connection using PostgreSQL 10 platform?
Could yould you please dump output of get_class($connection->getDatabasePlatform()) to see what platform is your connection using?

You're right. Platform class is for PostgreSQL 9.4 Doctrine\DBAL\Platforms\PostgreSQL94Platform. Command is OK when i switch to Doctrine\DBAL\Platforms\PostgreSQL100Platform.
Thank you!

That is version of your PostgreSQL server, but is your DBAL connection using PostgreSQL 10 platform?
Could yould you please dump output of get_class($connection->getDatabasePlatform()) to see what platform is your connection using?

Where and how can I dump it?

Was this page helpful?
0 / 5 - 0 ratings