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

PostgreSQL migration with reserved word double quoted in up() but not in down() #5928

Open
cpetit-sigma-fr opened this issue Feb 16, 2023 · 4 comments

Comments

@cpetit-sigma-fr
Copy link

cpetit-sigma-fr commented Feb 16, 2023

Bug Report

Encountered within a Symfony 5.4 project using a PostgreSQL 12.x database, with a field named row.

Q A
BC Break no
Version 2.14.1

Summary

Current behavior

How to reproduce

Create or update an entity with a row attribute.

I didn't take the time to try with other reserved SQL words.

Make a new migration, the generated code is like this:

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE configuration ALTER "row" DROP NOT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('ALTER TABLE configuration ALTER row SET NOT NULL');
    }

Expected behavior

The ALTER TABLE line in down() method should enclose row in double quotes, as it's done in up() one:

        $this->addSql('ALTER TABLE configuration ALTER "row" SET NOT NULL');
@greg0ire greg0ire transferred this issue from doctrine/orm Feb 16, 2023
@greg0ire
Copy link
Member

Transferring to the DBAL since it is responsible for generating the diff.
Possible next steps: reproduce this in a test case with the DBAL APIs.

You can see here how doctrine/migrations uses the DBAL: https://github.com/doctrine/migrations/blob/e542ad8bcd606d7a18d0875babb8a6d963c9c059/lib/Doctrine/Migrations/Provider/DBALSchemaDiffProvider.php#L48-L53

@derrabus
Copy link
Member

Also, the DBAL version in use wold be interesting.

@cpetit-sigma-fr
Copy link
Author

3.5.3, as reported by:

php bin/composer show | grep -i dbal
doctrine/dbal 3.5.3 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and ...

@stof
Copy link
Member

stof commented Mar 17, 2023

I'm quite sure this is due to #5776

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants