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

orm:schema-tool:update tries to change columns without changes #5870

Closed
DASPRiD opened this issue Jun 11, 2016 · 2 comments
Closed

orm:schema-tool:update tries to change columns without changes #5870

DASPRiD opened this issue Jun 11, 2016 · 2 comments

Comments

@DASPRiD
Copy link

DASPRiD commented Jun 11, 2016

While working a little with custom types in Doctrine lately, I recently noticed a bug in the Comparator, although its roots are deeper down. Consider having a custom type like this:

class CustomType extends Type
{
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
    {
        return $platform->getBinaryTypeDeclarationSQL([
            'length' => '16',
            'fixed' => true,
        ]);
    }

    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        // …
    }

    public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        // …
    }

    public function requiresSQLCommentHint(AbstractPlatform $platform)
    {
        return true;
    }

    public function getName()
    {
        return 'CustomType';
    }
}

Now, when using that type in an entity, at first when generating the database SQL and inserting it, everything is fine. The column has the correct type (binary, fixed 16) and a comment denoting the "CustomType" type.

The problem now is when asking the schema-tool for a diff. Even though the column using that type wasn't changed, the schema-tool suggests an ALTER TABLE statement, changing the column to exactly what it already is.

I looked a bit into this, and it seems that the problem is that the Schema generated from the mapping files does not include the columns comment, length, fixed status and also that the type in the Schema coming from the DB has Binary as type, instead of CustomType. This lets the Comparator think it needs to update the column.

This problem looks rather complex to me, and I have no real idea on how to solve this, maybe someone else who has a better insight can analyse this further.

@beberlei
Copy link
Member

@DASPRiD This is a DBAL issue, please re-open the ticket there.

@DASPRiD
Copy link
Author

DASPRiD commented Jun 12, 2016

Re-created the issue under doctrine/dbal: doctrine/dbal#2411

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

No branches or pull requests

2 participants