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

DDL generated repeatedly on schema:update with same Schema, if "default" value is missing #6845

Open
octaharon opened this issue Nov 23, 2017 · 2 comments

Comments

@octaharon
Copy link

octaharon commented Nov 23, 2017

That seems quite a minor bug but still can cause some problems, esp. when using Migrations bundle

So if an entity has a field described like that
@ORM\Column(name="field", type="integer", length=8, options={"default"})

it doesn't cause any errors both on schema:update or schema:validate, but they repeatedly report a difference in that field, and "update" tries to perform the following query
ALTER TABLE some_table CHANGE field field INT NOT NULL;
and it will generate it continiously on every update or migration:diff despite nothing changes

if "default" or the whole "options" property is removed, everything is working as expected
Same applies if default value is actually specified and valid:
@ORM\Column(name="field", type="integer", length=8, options={"default": 1 })

So the issue is only due to incorrect field specification, but it's never stated that it's incorrect. Another question is how the Schema tool should behave in this particular scenario. I would assume that "default" is NULL, and if the column has nullable=false at the same time than it should cause a validation error at least.

Doctrine version used:
"doctrine/common": "^2.8", "doctrine/dbal": "^2.6", "doctrine/doctrine-bundle": "^1.7", "doctrine/doctrine-cache-bundle": "^1.2", "doctrine/doctrine-migrations-bundle": "^1.3", "doctrine/orm": "^2.5",

RDBMS affected (which I have tested):

  • MySQL 5.7
  • MariaDB 10.1
  • MariaDB 10.2 (which also has a bunch of other issues but not relevant)
@lcobucci
Copy link
Member

@octaharon this is a DBAL issue, and it looks like it's related to doctrine/dbal#2850 and doctrine/dbal#2825. Could you please check if these PRs fixes your problem (and maybe move this discussion to DBAL instead)?

@octaharon
Copy link
Author

octaharon commented Nov 27, 2017

No, I believe it's not related, since I can reproduce it on MySQL server as well. Despite that I've tried both PR's - didn't change anything regarding the issue mentioned.
My point was not that the behaviour itself should be considered "invalid", it's just neither documented nor validated to declare a field with options={"default"}. So it's not really clear how it SHOULD behave with things like this. And in my particular case it was quite a nuisance to locate the reason my migrations failed, cause the aformentioned declaration causing that was clearly just a typo, which, if you ask me, should invoke a schema validation error at least.

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