mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDL generated repeatedly on schema:update with same Schema, if "default" value is missing #5784
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @octaharon on GitHub (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=falseat 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):
@lcobucci commented on GitHub (Nov 24, 2017):
@octaharon this is a DBAL issue, and it looks like it's related to https://github.com/doctrine/dbal/pull/2850 and https://github.com/doctrine/dbal/pull/2825. Could you please check if these PRs fixes your problem (and maybe move this discussion to DBAL instead)?
@octaharon commented on GitHub (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.