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

Register Custom Doctrine Column Type Mappings #269

Closed
zschuessler opened this Issue Nov 29, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@zschuessler
Copy link

zschuessler commented Nov 29, 2016

When using the enum or json types (or any others doctrine doesn't map natively, yet), an uncatched fatal error results.

This isn't necessarily a problem with CRUD, but for a more dev-friendly experience we could add defaults for these column types.

Column maps are called here:
https://github.com/Laravel-Backpack/CRUD/blob/master/src/PanelTraits/AutoSet.php#L17

Here's a hacky solution (need something more user-extensible, but you get the idea)

public function setFromDb()
    {
        $this->addCustomDoctrineColumnTypes(); // let's add some defaults, eh?
        $this->getDbColumnTypes();
public function addCustomDoctrineColumnTypes()
    {
        $dbPlatform = \Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
        $dbPlatform->registerDoctrineTypeMapping('enum', 'string');
        $dbPlatform->registerDoctrineTypeMapping('json', 'json_array');
    }

Not sure what implications this could have since I'm not aware of the full CRUD architecture. I will say, though, that native support in Laravel&dbal is a hot topic that probably won't resolve soon.

If you want to reproduce this problem, just make a json or enum column in a migration, and try to view a CRUD list page. I'm running on MySQL 5.7.16, which has json column support.

@OwenMelbz OwenMelbz referenced this issue Dec 4, 2016

Closed

[Backlog] Known limitations/bugs/future features. #285

12 of 18 tasks complete
@OwenMelbz

This comment has been minimized.

Copy link
Member

OwenMelbz commented Dec 4, 2016

Hi @zschuessler

I'm just consolidating a list of issues like this which can be seen #285 so I'm going to close this to keep the area tidy, but it will still be referenced :)

@OwenMelbz OwenMelbz closed this Dec 4, 2016

@zschuessler

This comment has been minimized.

Copy link

zschuessler commented Dec 6, 2016

Posting for future PR.. any custom mappings must appear here too:

https://github.com/Laravel-Backpack/CRUD/blob/master/src/CrudTrait.php#L44

@muya

This comment has been minimized.

Copy link

muya commented Jan 2, 2017

In case anyone's looking, I detailed my implementation of @zschuessler's fix here: https://goo.gl/ac3Eks

@zschuessler

This comment has been minimized.

Copy link

zschuessler commented Jan 2, 2017

Well done! Nice post :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment