-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 text column length change #3182
Conversation
After this change, the correct DDL statement is generated for you? |
I need to check this later today and also use the non strict comparison (!=) instead. I suppose this is why Travis failed and I guess that's why it's not strict for the StringType case.
|
This is fixing a Travis test issue with Doctrine\Tests\DBAL\Functional\Schema\MySqlSchemaManagerTest::testDiffListTableColumns where it's comparing 0 to null which shouldn't be considered as a changed column. https://travis-ci.org/doctrine/dbal/jobs/390012492
@jwage I've successfully tested it using Laravel with MySQL and all migrations i tried switching between text, mediumtext and longtext where executed correctly. The DDL was correct. Laravel doesn't support tinytext, so i didn't do that. Regarding the travis failing test, I think it's out of my scope and not sure how to proceed. Either the failing test is wrong or there's a deeper issue with the field's length default handling in dbal. Let me explain the issue: What do you think about this issue and the failing test? In my opinion, it should use the strict comparison (but could also stay with the non-strict one) and fix the failing test with explicit length or by checking manually if the diff is the text column's length and ignore it. I don't have any more capacity atm to dive deeper in dbal. |
With MySQL, changing the test to explicitly state the text length has the following results:
The longtext shouldn't be failing but, as i said, the case is missing when the table is read. |
Any chance to get the tests fixed to have this merged ? Is there another workaround for the time being ? |
For until doctrine/dbal#3182 is merged.
For until doctrine/dbal#3182 is merged.
Any chance of this getting fixed? @cbotsikas a suggestion to fix the failing test. Try this: if (($properties1['length'] > 0 || $properties2['length'] > 0) && (int) $properties1['length'] !== (int) $properties2['length']) {
$changedProperties[] = 'length';
} |
It seems the changes break sqlsrv and ibm_db2 tests. Any chances that you can make your changes work with them too? |
Closing as stale. The issue should be addressed by #4659. |
Summary
Schema Comparator's diffColumn did not check if the length had changed when the column type was Text. In MySQL it wasn't possible to change between TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT.
I've added a new check for TextType where i only check if the length property is the same in both columns. I did not append the case with StringType and BinaryType because 'fixed' property doesn't apply to TextType and the default 'length' of 255 feels wrong.
I've included a test case.