[PR #7554] Allow all datetime types to be used as version #10540

Closed
opened 2026-01-22 16:07:54 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/7554

State: closed
Merged: No


I am working on an existing database with fields of type timestamp. In order to map that to a DateTime object in Doctrine, I've found the solution of adding the @Version annotation. But I'd really prefer to get a DateTimeImmutable, which is impossible.

At the moment a field of type datetime_immutable with annotation @Version will trigger this following error:

Locking type "datetime_immutable" (specified in "App\Entity\Bakery", field "createdAt") is not supported by Doctrine.

I cannot see any reason not to allow any type of datetime to be mapped to a timestamp in database, so this PR allows all of them. Please tell me if i'm missing something.

**Original Pull Request:** https://github.com/doctrine/orm/pull/7554 **State:** closed **Merged:** No --- I am working on an existing database with fields of type `timestamp`. In order to map that to a DateTime object in Doctrine, I've found the solution of adding the `@Version` annotation. But I'd really prefer to get a DateTimeImmutable, which is impossible. At the moment a field of type `datetime_immutable` with annotation `@Version` will trigger this following error: ``` Locking type "datetime_immutable" (specified in "App\Entity\Bakery", field "createdAt") is not supported by Doctrine. ``` I cannot see any reason not to allow any type of datetime to be mapped to a timestamp in database, so this PR allows all of them. Please tell me if i'm missing something.
admin added the pull-request label 2026-01-22 16:07:54 +01:00
admin closed this issue 2026-01-22 16:07:54 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#10540