framework
framework copied to clipboard
[9.x] Prevent error in db/model commands when using enum columns
The PR resolves #43630 #43622
The doctrine/dbal
package does not support enum types when listing database columns. This PR adds support for mapping enum
and sysname
(issue with some distributions of sqlsrv) to string
. The Artisan db:show
, db:table
and model:show
commands have all been updated to use it.
Additonally, db:show
uses the rescue
helper to prevent an error if the engine type is not available. This PR also prevents the error from being reported.
@jbrooksuk @joedixon model:show command needs this mapping too
Thanks for addressing this @joedixon ! I opened a PR at #43645 for the same issue, so I guess my PR can be closed.
There are two things to consider concerning your implementation:
- the issue with
enum
types only seems to exist on MySQL databases, so we probably might want register the type mapping only on MySQL platforms. - the issue also exists for
point
types, so a mapping for these should probably also be added.
Hey @lupinitylabs - thanks for bringing the additional missing mapping to my attention. I've gone ahead and added some more that we were missing support for.
I'm not sure it's worth conditionally checking the database type as if it's only an issue with, for instance, MySQL, the other database types won't be impacted anyway.
Yes, I guess since we are just reading the structure anyways, just mapping it all to string might be fine.