Skip to content

Default values for floats cause the diff to be regenerated every time #1542

@PaulCombal

Description

@PaulCombal

Bug Report

Q A
BC Break no
Version 3.9.4

Summary

My column definition in a Symfony 7 entity:

    #[ORM\Column(options: ['default' => 0])]
    private ?float $otherFees = 0;

When I generate a diff, migrate, then regenerate a diff, the same line is always generated:

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE xxx CHANGE other_fees other_fees DOUBLE PRECISION DEFAULT 0 NOT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE xxx CHANGE other_fees other_fees DOUBLE PRECISION DEFAULT \'0\' NOT NULL');
    }

This only happens for floats.

Using ['default' => '0'] instead of ['default' => 0] yields the same result.

I'm using MySQL 8.0.36. I tried MySQL 8.4.7 with the same result.

Current behavior

A migration is always generated for entities with floats having a default value set.

How to reproduce

  1. Create an entity with this column definition
    #[ORM\Column(options: ['default' => 0])]
    private ?float $floatval = 0;
  1. Run d:m:diff
  2. Run d:m:m
  3. Run d:m:diff again

The same diff will be generated again.

Expected behavior

No new migration lines are generated for entities having a float default value set, if the default value is already set.

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