Closed ChrisThompsonTLDR closed 7 years ago
Hmm. Never tried Backpack on MariaDB. Theoretically it should work fine, but only the features that Eloquent supports for MariaDB.
It looks to me like the "enum" column type isn't supported by DBAL, so it's not supported by Eloquent, so it's not supported by Backpack :-)
Can you change that column type to string and use a select_from_array field?
Cheers!
Laravel and Eloquent support enum on MariaDB as far as I understand. I've used MariaDB to back dozens of Laravel 5.2 and 5.3 projects that have enum fields and have never encountered an issue.
Ok... in that case, try
$this->crud->setFromDb()
Does it work that way? setFromDb()
is pretty hit-and-miss right now, but it could be a real powerhouse in the future.
Cheers!
Interesting, that works.
I removed $this->crud->setFromDb()
and manually add the columns and fields.
Feel free to ping me if you want help testing changes to setFromDb() on MariaDB.
Glad it worked. Ok, great, thanks! Cheers.
$this->crud->addField([
'name' => 'plan',
'type' => 'enum',
]);
This appears to work properly, so I don't think it's the DBAL lib or Eloquent. It must be something about the way setFromDB()
gets information from the DB about the enum field.
@ChrisThompsonTLDR enum is commented out in the source here, and I wonder if that's related to the problem: https://github.com/Laravel-Backpack/CRUD/blob/6b2d202c714f36ed0fea75136b967c0f07e22d1e/src/PanelTraits/AutoSet.php#L96
I wish Laravel and Backpack could handle MySql enum columns.
you have to register enum type with registerDoctrineTypeMapping
i made it as helper function and call it before setFromDb , like this:
Helpers::setDoctrineTypesMapping(); $this->crud->setFromDb()
static public function setDoctrineTypesMapping(){ $types = ['enum' => 'string']; $platform = DB::getDoctrineConnection()->getDatabasePlatform(); foreach ($types as $type_key => $type_value) { if (!$platform->hasDoctrineTypeMappingFor($type_key)) { $platform->registerDoctrineTypeMapping($type_key, $type_value); } } }
@tabacitu commenting out the // $this->crud->setFromDb();
works. Thanks.
@bosz - I don't suppose you'd mind mentioning what version of the DB you were using - it seems some have mentioned MariaDB vs MySQL and MySQL itself isn't always consistent between minor versions?
I'm using pagekit and I'm having the same error where exactly I have to comment out this? // $this->crud->setFromDb();
It's exactly this pull: #176
Running MariaDB 10.
My composer.json