-
Notifications
You must be signed in to change notification settings - Fork 177
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
Carbon mapping types #371
Comments
Doctrine's documentation on custom mapping yypes, mentions that registering a doctrine type mapping is meant to be used for database schema management. In order for the 'custom_types' => [
'date' => DoctrineExtensions\Types\CarbonDateType::class,
'datetime' => DoctrineExtensions\Types\CarbonDateTimeType::class,
'datetimetz' => DoctrineExtensions\Types\CarbonDateTimeTzType::class,
'time' => DoctrineExtensions\Types\CarbonTimeType::class,
], As a warning, there is a bug with migrations when two types use the same 'custom_types' => [
'carbondate' => DoctrineExtensions\Types\CarbonDateType::class,
'carbondatetime' => DoctrineExtensions\Types\CarbonDateTimeType::class,
'carbondatetimetz' => DoctrineExtensions\Types\CarbonDateTimeTzType::class,
'carbontime' => DoctrineExtensions\Types\CarbonTimeType::class,
'date' => DoctrineExtensions\Types\CarbonDateType::class,
'datetime' => DoctrineExtensions\Types\CarbonDateTimeType::class,
'datetimetz' => DoctrineExtensions\Types\CarbonDateTimeTzType::class,
'time' => DoctrineExtensions\Types\CarbonTimeType::class,
], |
The fix for the bug with migrations will be fixed in doctrine/dbal 2.9.3. |
Package version, Laravel version
laravel-doctrine: 1.4
laravel: 5.7
Context
I have a static and dynamic database connection. The dynamic connection is configured at runtime and the entity manager is reset after that.
Expected behaviour
An entity with a
datetime
field should contain aCarbon
instance for this field becausedatetime
is mapped tocarbondatetime
.Actual behaviour
I have an entity handled by the static connection manager that has a
datetime
field. When I inspect this entity object, this field is of typeDatetime
. Only when I change it's type tocarbondatetime
, the field's type is aCarbon
instance.For the entity handled the dynamic connection manager, the same thing happens.
The mapping doesn't seem to work
Steps to reproduce the behaviour
I have installed the laravel-doctrine/extensions package and tried both registering the default service provider, and a custom service provider as mentioned here.
I have added
'carbondatetime' => \DoctrineExtensions\Types\CarbonDateTimeType::class
todoctrine.custom_types
.For the static connection I have added
'datetime' => 'carbondatetime'
tomapping_types
. For the dynamic connection I update themapping_types
config array right before resetting the manager because otherwise I get access denied exception (there is no valid connection config at boot).The text was updated successfully, but these errors were encountered: