-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
DateTimeImmutable error with default value CURRENT_TIMESTAMP #2859
Comments
Duplicate of doctrine/orm#6698 ? |
I don't believe so no. This is only an issue with the 'newly' released DateTimeImmutable and works fine with DateTime. EDIT: |
This should be fixed by #2835, but we should consider a separate fix for 2.6 since that PR can't go to 2.6,... |
It has been fixed by #2835, but since I have no timeline for when that PR will be released, a fix for 2.6 would be welcomed with open arms from my part. |
The fact that #2835 fixes this as a side-effect is not OK for this patch to go through: needs a dedicated test and an ad-hoc fix for 2.6 if you need it there. |
And yep, still using |
I gave it a go at #2861 with |
Thanks for breaking the ability to have the option of having a CURRENT_TIMESTAMP set to default. We use Symfony to handle migrations and have other technologies which user the DB, and now due to this "fix" (or downgrade), I'm unable to set a default timestamp into the schema. Not happy about this "fix" at all, why was it removed ? Makes no sense and is a BAD decision, giving LESS flexibility to us developers. |
@spacetraveller Please open new issue for your problem referencing this one. If possible, also provide a test case for the broken use case. Thanks. |
Hey Majk578, please see #3142 for the detaiils of the issue. |
Reminder to not use |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I have just changed all my DateTime to DateTimeImmutable and I experienced an issue with the ones where I had a CURRENT_TIMESTAMP default value:
The issue occurs when I use the schema-tool to update my database and I get the following error:
So I learned that the schema-tool tries to execute a query with a string as default value, which is the reason for the error. If I use the DateTime type instead, it will execute it as expected.
I went digging and I found the method 'getDefaultValueDeclarationSQL' in the AbstractPlatform class, where I found a solution for the issue.
And if I add 'DateTimeImmutable' to the following line:
It works as intended. Any chance this can be implemented? I haven't seen any documentation about this being intentional, so I figured it wasn't.
The text was updated successfully, but these errors were encountered: