framework icon indicating copy to clipboard operation
framework copied to clipboard

[9.x] Prevent error in db/model commands when using enum columns

Open joedixon opened this issue 2 years ago • 1 comments

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.

joedixon avatar Aug 10 '22 08:08 joedixon

@jbrooksuk @joedixon model:show command needs this mapping too

mziraki avatar Aug 10 '22 08:08 mziraki

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:

  1. 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.
  2. the issue also exists for point types, so a mapping for these should probably also be added.

lupinitylabs avatar Aug 10 '22 20:08 lupinitylabs

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.

joedixon avatar Aug 11 '22 11:08 joedixon

Yes, I guess since we are just reading the structure anyways, just mapping it all to string might be fine.

lupinitylabs avatar Aug 11 '22 14:08 lupinitylabs