mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Mapping datetime database columns to date properties raises ConversionException
#6363
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 @sGy1980de on GitHub (Dec 12, 2019).
Bug Report
Summary
I got somewhat surprised by an unexpected mapping issue when i wanted to convert
datetimecolumns todatecolumns. The model was once created with adatetimeproperty, when onlydatewas needed. I spent quite some time in creating a (for my understanding) zero downtime migration script, which addresses the issue and still keeps the API alive during transition.Current behavior
Mapping
datetimevalues in the database to properties mapped with typedateis currently not possible. This results in aDoctrine\DBAL\Types\ConversionExceptionHow to reproduce
datetimemapped property and fill database with some rowsdatetimetodatefor the propertytime-indexedvalues to the nowdatetype mapped propertyExpected behavior
The ORM should truncate the
time-indexfrom the database value on it's own and only use thedatepart.Further notes
Even more surprising to me. The ORM maps
datevalues todatetimemapped properties without issues. So the migration would have worked the other way around with no issues.