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

Merge MySQL 5.7.9 (GA) semantics into MySQL57Platform #2653

Merged
merged 1 commit into from
May 9, 2017

Conversation

deeky666
Copy link
Member

@deeky666 deeky666 commented Feb 9, 2017

This is adopted from #2266 and #2455 and contains additional fixes, adjustments and upgrade notice.

I made the following decisions about this whole topic:

  • Merge the changes into MySQL57Platform as suggested by @beberlei because the first GA version of the 5.7 series is 5.7.9
  • Accept possible minor BC breaks when upgrading the schema (tracked in UPGRADE.md)
  • Do not care about invalid values previously store in json_array type columns (they would be invalid with 2.5 anyways so what's the point?)
  • Did I forget anything? Please let me know.


if (version_compare($version, '5.7', '>=')) {
if ($majorVersion === '5' && $minorVersion === '7' && null === $patchVersion) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, use Yoda condition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed


public function testReturnsJsonTypeDeclarationSQL()
{
$this->assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Support for PHP < 7 has been dropped at master. Could we use [] instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

@phansys is that really important here? We would need to fix all of that stuff in one PR anyways.

@robhogan
Copy link

robhogan commented Feb 10, 2017

[Edit: Petulant complaint retracted with apologies]

@Ocramius
Copy link
Member

Ocramius commented Feb 10, 2017

[Edit: snarky response retracted, apologies accepted 👍 ]

@deeky666
Copy link
Member Author

@rh389 I did not intend to rip anyone's work off. Originally I wanted to use either of the previous PRs getting merged but both of them were lacking some things. #2266 need merge into MySQL57Platform, #2455 needed keywords, tests, documentation etc. And both of them did not have the upgrade entry. As many people like you want to get this finally going, I decided to take a "fast" approach by using what was already contributed (btw see the @author tag in MySQL57Platform) and put the missing pieces in. So much to ripping off.
As to why this took 14 months, as you might have noticed, I took a year off of OS development last year (more or less) and I apologize if that might have been frustrating to some, but we all do this in our free time and have personal lives beside Doctrine.

@robhogan
Copy link

Sorry @deeky666, I was out of order. It was frustrating to work on this issue without a response but that's OS sometimes, not your fault. Apologies again, thanks for you efforts and looking forward to seeing this land.

UPGRADE.md Outdated
MySQL 5.7 ships with native JSON type support which now is adopted by DBAL.
If you are using MySQL 5.7 and have columns with ``json_array`` type defined in your database,
utilizing DBAL's schema comparator will cause a schema diff, where the previously used native type
``LONGTEXT`` will be changed to ``JSON``.

Choose a reason for hiding this comment

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

I'm not sure this is actually true - the Comparator doesn't inspect the actual column type so won't pick up the change (unless/until it has some other reason to alter that column). See #2266 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

@rh389 good point. Considering that, I can remove the upgrade notice again I suppose unless there are other reasons why BC could not be maintained here. Currently I can't think of any.

Choose a reason for hiding this comment

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

Well, it will alter to a native JSON type later if the user changes their column definition some other way, which might be a bit unexpected (buggy?) but I guess technically not a BC break.

When the column is updated though it's actually quite likely to fail in practice because the LONGTEXT implementation used an empty string as a default value, which is invalid for native JSON. It's not just the case that it'll only fail if the user was doing something weird.

Not a blocker IMO - just making sure you're aware.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, there is nothing we can do about it if we want to move on. I'll remove the upgrade notice then.

@deeky666
Copy link
Member Author

@Ocramius @phansys @rh389 this thing is ready from my point of view. Anything we forgot?

Copy link
Contributor

@phansys phansys left a comment

Choose a reason for hiding this comment

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

Status: Needs work.

@@ -241,6 +242,7 @@ protected function getKeywords()
'SSL',
'STARTING',
'STRAIGHT_JOIN',
'STORED',
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be placed after 'STARTING' and before 'STRAIGHT_JOIN' in order to keep the current sorting.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

public function testInitializesJsonTypeMapping()
{
$this->assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
$this->assertEquals('json_array', $this->_platform->getDoctrineTypeMapping('json'));
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use assertSame() instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@Omranic
Copy link

Omranic commented Apr 12, 2017

@deeky666 @Ocramius @phansys @rh389 Is this PR landing anytime soon?! 🤔 Thanks in advance

@deeky666
Copy link
Member Author

@Omranic waiting for an approval and merge from one of the other core members.

@mpyw
Copy link

mpyw commented May 9, 2017

Pending for 27 days......

@Ocramius
Copy link
Member

Ocramius commented May 9, 2017 via email

@kimhemsoe
Copy link
Member

@deeky666 Looks good to me

@mpyw
Copy link

mpyw commented May 9, 2017

@kimhemsoe @deeky666 I'm also using the branch in my product and working fine 👍

@Ocramius Ocramius self-assigned this May 9, 2017
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

@Ocramius Ocramius merged commit e98d241 into doctrine:master May 9, 2017
@mpyw
Copy link

mpyw commented May 9, 2017

@Ocramius Thank you ✨

@le-martre
Copy link

Hello guys, first of all thanks a lot for your work.
I have a small question though, I upgraded to PHP7.1 and dbal 2.6.1 especially to fix a bug that I'm currently experiencing. I'm just trying to create a json database field in one of my laravel migrations.

I still get this message though :

[Doctrine\DBAL\DBALException]                                                                 
  Unknown database type json requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support   
  it. 

Which makes me think that MySQL57Platform is never used or acknowledged? Any hints about where it could come from? Thanks in advance! Have a great week.

@Ocramius
Copy link
Member

@MartinVandersteen please report a separate issue with a way to reproduce it.

@le-martre
Copy link

I don't think there is any way I could find a way to reproduce it, just asking if something has to be done at some point for Dbal to understand it has to use MySQL57 ? On what ground does it decide which one to use?

@Ocramius
Copy link
Member

just asking if something has to be done at some point for Dbal to understand it has to use MySQL57

See

$this->platform = $this->_driver->createDatabasePlatformForVersion($version);

A test would:

  • connect to a DB
  • create the schema
  • try to introspect the schema and verify that the "json" type was correctly detected

That said, please report further findings on a new issue.

@hansbogert
Copy link

hansbogert commented Nov 14, 2018

The Type matrix does not reflect this change. In fact it doesn't show the json type at all. (it does show the deprecated json_array)

https://www.doctrine-project.org/projects/doctrine-dbal/en/2.8/reference/types.html#mapping-matrix

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.