Skip to content

[9.x] Enhance column modifying #43541

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

Closed
wants to merge 7 commits into from
Closed

[9.x] Enhance column modifying #43541

wants to merge 7 commits into from

Conversation

hafezdivandari
Copy link
Contributor

Before this PR, we were manually map Laravel column types to its Doctrine equivalent and many types were missing, this PR uses each database platform own map instead. So we can support modifying many more columns, e.g. double, float, jsonb, set, timeTz, timestamp (no need to register a custom Doctrine type class), timestampTz, tinyText, unsignedDecimal, unsignedDouble, unsignedFloat, year, etc.

It also fix a bug when modifying a binary column that were being changed to LONGBLOB instead of BLOB.

Here is the Doctrine type mapping of:

@driesvints
Copy link
Member

There are several breaking changes to method signatures in this PR.

@hafezdivandari
Copy link
Contributor Author

@driesvints I fixed that in a new commit and reverted all changes on method signatures.

$options['length'] = static::calculateDoctrineTextLength($fluent['type']);
}

if ($fluent['type'] === 'binary') {
$options['length'] = AbstractMySQLPlatform::LENGTH_LIMIT_BLOB;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use MySQL platform? What if user is using SQL Server?

Copy link
Contributor Author

@hafezdivandari hafezdivandari Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (static::doesntNeedCharacterOptions($fluent['type'])) {
if ($fluent['type'] === 'timestamp') {
$options['platformOptions'] = [
'version' => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "version" = true even mean though?

Copy link
Contributor Author

@hafezdivandari hafezdivandari Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They use this option on MySQL and DB2 only on datetime type. That's the only way to convert datetime to timestamp. but I don't know why they call it "version" if that's the question.


if ($fluent['type'] === 'jsonb') {
$options['platformOptions'] = [
'jsonb' => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default => 255 + 1,
'tinyText' => AbstractMySQLPlatform::LENGTH_LIMIT_TINYTEXT,
'text' => AbstractMySQLPlatform::LENGTH_LIMIT_TEXT,
'mediumText' => AbstractMySQLPlatform::LENGTH_LIMIT_MEDIUMTEXT,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why MySQL specific?

Copy link
Contributor Author

@taylorotwell taylorotwell marked this pull request as draft August 16, 2022 15:57
@taylorotwell
Copy link
Member

Please mark as ready for review when all questions are answered. Thanks.

@hafezdivandari hafezdivandari marked this pull request as ready for review August 16, 2022 17:36
@hafezdivandari
Copy link
Contributor Author

@taylorotwell Thank you for reviewing this PR. I answered all.

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

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.

4 participants