Skip to content
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

[9.x] Support modifying a char column type #41320

Merged
merged 1 commit into from
Mar 3, 2022
Merged

[9.x] Support modifying a char column type #41320

merged 1 commit into from
Mar 3, 2022

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Mar 3, 2022

This PR provides support for modifying a char column type.

Schema::table('users', function (Blueprint $table) {
    $table->char('name', 50)->nullable()->change();
});

Before this PR, modifying a char column led to an error:

Unknown column type \"char\" requested. Any Doctrine type that you use has to be registered with \\Doctrine\\DBAL\\Types\\Type::addType(). You can get a list of all the known types with \\Doctrine\\DBAL\\Types\\Type::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information

But doctrine/dbal package actually supports modifying char column types as StringType::class by setting fixed option to true.

So this PR, maps Laravel char to its Doctrine equivalent string type and set fixed option to true that finally gets the SQL snippet to declare a CHAR column.

@taylorotwell
Copy link
Member

Can you describe how you determined these changes were needed and what the problem was before this fix?

@taylorotwell
Copy link
Member

Please mark as ready once you have done so.

@taylorotwell taylorotwell marked this pull request as draft March 3, 2022 14:51
@hafezdivandari
Copy link
Contributor Author

@taylorotwell sure, I updated my comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants