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

Fix BC-break regarding JsonArrayType #2855

Merged
merged 3 commits into from
Nov 18, 2017

Conversation

lcobucci
Copy link
Member

As reported on #2782 (comment) we've introduced a BC-break on 2.6.x regarding the json_array type. This fixes it for good.

*/
public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComment()
{
if ( ! $this->_sm->getDatabasePlatform()->hasNativeJsonType()) {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this test also run on anything with TEXT support?


self::assertFalse($tableDiff);

$this->_sm->dropTable('json_array_test');
Copy link
Member

Choose a reason for hiding this comment

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

Should be done in tearDown or such: otherwise, a failure in this test can lead to other failures in colliding table names in tests

$comparator = new Comparator();
$tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_array_test'), $table);

$this->_sm->dropTable('json_array_test');
Copy link
Member

Choose a reason for hiding this comment

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

Should be done in tearDown or such: otherwise, a failure in this test can lead to other failures in colliding table names in tests

$comparator = new Comparator();
$tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_array_test'), $table);

$this->_sm->dropTable('json_array_test');
Copy link
Member

Choose a reason for hiding this comment

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

Should be done in tearDown or such: otherwise, a failure in this test can lead to other failures in colliding table names in tests


$comparator = new Comparator();
$tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_test'), $table);
$this->_sm->dropTable('json_test');
Copy link
Member

Choose a reason for hiding this comment

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

Should be done in tearDown or such: otherwise, a failure in this test can lead to other failures in colliding table names in tests

}

$table = new Table('json_array_test');
$table->addColumn('id', 'integer');
Copy link
Member

Choose a reason for hiding this comment

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

Can you drop columns that aren't strictly required?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure...

);

$table = new Table('json_array_test');
$table->addColumn('id', 'integer');
Copy link
Member

Choose a reason for hiding this comment

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

Can you drop columns that aren't strictly required?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure...

);

$table = new Table('json_array_test');
$table->addColumn('id', 'integer');
Copy link
Member

Choose a reason for hiding this comment

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

Can you drop columns that aren't strictly required?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure...

);

$table = new Table('json_test');
$table->addColumn('id', 'integer');
Copy link
Member

Choose a reason for hiding this comment

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

Can you drop columns that aren't strictly required?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure...

}

$this->_conn->executeQuery(
'CREATE TABLE json_test (id INT NOT NULL, parameters JSON NOT NULL, PRIMARY KEY(id))'
Copy link
Member

Choose a reason for hiding this comment

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

Is this because you need to reproduce half-migrated column definitions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeap, that ensures we won't break things baddly

@lcobucci
Copy link
Member Author

@Ocramius @deeky666 @alcaeus any idea on why Oracle is failing on that way? I mean, the table has only one column and it's not part of the changedProperties WTF?

@lcobucci lcobucci force-pushed the bc-break/fix-json_array-fields branch from 9058153 to 3b5c771 Compare November 18, 2017 20:26
On 31d0128 we made JsonType the default
one, which caused some unexpected results with the comparator.

This tests validates that if users have a JSON column but are using the
JsonArrayType we'll just add a comment to the column.

Reference: doctrine#2782
And then we don't need to wait till v3 to not require comments on the
JsonType.
@lcobucci lcobucci force-pushed the bc-break/fix-json_array-fields branch from 3b5c771 to c90b26e Compare November 18, 2017 20:32
@lcobucci lcobucci changed the title [WIP] Fix BC-break regarding JsonArrayType Fix BC-break regarding JsonArrayType Nov 18, 2017
@lcobucci
Copy link
Member Author

Ok, I've found out that Oracle returns the modified columns using uppercase instead... tests updated and hopefully everything will work fine

@lcobucci lcobucci removed the WIP label Nov 18, 2017
@lcobucci lcobucci dismissed Ocramius’s stale review November 18, 2017 20:35

Requested changes have been applied

I know, this is REALLY nasty but that was the only way I've found to
make it work properly.
@lcobucci lcobucci force-pushed the bc-break/fix-json_array-fields branch from c90b26e to 104793c Compare November 18, 2017 21:18
@lcobucci lcobucci merged commit 39cb21b into doctrine:master Nov 18, 2017
@lcobucci lcobucci deleted the bc-break/fix-json_array-fields branch November 18, 2017 21:31
lcobucci added a commit to lcobucci/dbal that referenced this pull request Nov 18, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 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.

2 participants