Skip to content

Generated SQL no longer adheres to the order of fields #1518

@jannes-io

Description

@jannes-io

BC Break Report

Q A
BC Break yes
Version 3.9.1

(ORM: 3.5.0, DBAL: 4.2.4)

Summary

Traits are now appended to the end of the generated SQL in CREATE TABLE instead of where they actually belong when running migrations:diff

Given the following setup:

trait IdentifiableEntity
{
    #[ORM\Id]
    #[ORM\Column(type: Types::INTEGER)]
    #[ORM\GeneratedValue]
    private int $id;

    public function getId(): int
    {
        return $this->id;
    }
}

class MyEntity
{
    use IdentifiableEntity;

    #[ORM\Column(length: 255)]
    public string $name;
}

Previous behavior

It generated:

$this->addSql('CREATE TABLE my_entity (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`');

Current behavior

Now it generates:

$this->addSql('CREATE TABLE my_entity (name VARCHAR(255) NOT NULL, id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`');

How to reproduce

Set up the class above in an empty Symfony project with orm 3.5 and dbal 4.2 installed, and run bin/console doc:mig:dif.
If you can't reproduce, I can create a small demo app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions