-
-
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
Drop type comments entirely #5107
Conversation
51d7bc8
to
66bbeb6
Compare
Debugged it, and it's just because of the comment of course :) |
a89b28f
to
a4da59d
Compare
The remaining failures are with IBM DB2 and SQL Server, I don't know how to debug them, so I'm going to create the ORM and migration PRs instead |
Which test are you referring to? |
The test on SQL Server fails because of this: dbal/src/Platforms/SQLServerPlatform.php Lines 510 to 513 in d78267c
You replaced the call to EXEC sp_updateextendedproperty N'MS_Description', N'foo', N'SCHEMA', 'dbo', N'TABLE', 'sqlsrv_column_comment', N'COLUMN', commented_type
-- SQLSTATE [42000, 15217]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Property cannot be updated or deleted. Property 'MS_Description' does not exist for 'dbo.sqlsrv_column_comment.commented_type'. The tests on IBM DB2 fail because ... surprise ... it doesn't support boolean columns, as well as dbal/src/Platforms/AbstractMySQLPlatform.php Line 1052 in dfdb5fb
After some more research, of the two - SMALLINT DEFAULT '0' NOT NULL
+ SMALLINT DEFAULT 0 NOT NULL I would consider it a separate issue (#5108). dbal/src/Platforms/AbstractPlatform.php Lines 2599 to 2601 in a4da59d
|
Sorry, I was referring to dbal/tests/Functional/Schema/MySQLSchemaManagerTest.php Lines 358 to 371 in 4d66064
|
a4da59d
to
90f99c4
Compare
cf5992c
to
de2b2ef
Compare
No! Please do not remove DC2Type comments! Following post #5194 (comment) . a) Different DBAL Types, even if stored in the same DB column type, can have the values encoded differently. Without DC2Type comments, it is impossible to distinguish between such data/DB state and diff/migrate them correctly. b) We use the DC2Type comments also in DB triggers to further enforce the data integrity. Without DC2Type comments, it is impossible to distinguish between different DBAL Types on the server side. In summary, the DC2Type comments provide a very valuable and irreplaceable metadata stored together with the column definition, and they should stay forever. |
The DBAL maintains column comments for its internal purposes which is irrelevant as of #4746. If the application needs to maintain column comments for its own purposes, it should do so by its own means. |
@morozov I'm not sure how to interpret the remaining failures… |
It does and it doesn't. This is a remainder of the issue described in #5107 (comment) and partially fixed in #5108. DB2 doesn't support boolean columns natively, so the DBAL emulates them via SMALLINT. The same applies to MySQL and Oracle. During schema introspection, the DBAL converts non-boolean columns back to boolean to satisfy the comparator:
But there's no hack for this for DB2, hence the failure. Most likely, we can reproduce a scenario where an integer column is mistakenly introspected as a boolean on these platforms and consider it a bug. We could add the same hack for DB2 to satisfy the test but I'd argue that this condition in the comparator is the problem: dbal/src/Platforms/AbstractPlatform.php Line 4021 in de2b2ef
In the context of schema migration, if two column declarations yield the same SQL, it doesn't matter if they are of the same type or not. We could try removing this block and see if it yields any unexpected effects. Not having this condition may help get rid of the above hacks in the MySQL and Oracle platforms as well. P.S.: doing the above would fix one of the two failures. The remaining one (where the platform unaware comparison is used) is a known limitation of the old API. P.P.S.: given that the old comparison logic relies on the comments and it's still supported in 3.x, we can only drop the comments in 4.0 where the old API is not supported. |
I'll extract the comparison loosening in a separate PR then. |
da17080
to
a90b710
Compare
0eb249e
to
28769de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, just needs some more cleanup. I believe the commits should be squashed. The first one will likely break the build.
This feature is only useful for reverse-engineering purposes since we have platform-aware comparison. Reverse-engineering is not enough to justify having that feature, and ORM metadata reverse-engineered from the database can still be adjusted afterwards.
28769de
to
eb1729d
Compare
Looks good! I thought a bit about the upgrade impact, and the consequences look quite straightforward. If I have a commented type in 3.x which appends its type comment to the deployed column, when I upgrade to 4.0.0, there will be a schema diff since the DBAL will no longer expect the type comment and will remove it. Maybe the above combined with some actual schema changes will produce unexpected results but I can't think of anything right now. |
With this change, what method should be overrided to add a comment about the DBAL Type to DB column? |
@mvorisek I don't know that there is one. |
@morozov Just a question: I have defined a custom type, which uses DC2Type comment as of now (3.5) . After this change, will a new migration being generated (after diffing the schema) ? If yes, do you have any idea to solve this in the application? Thanks! PS: Read #4749
The idea seems legit. Just a little worried about how does it really work |
This feature is only useful for reverse-engineering purposes since we
have platform-aware comparison. Reverse-engineering is not enough to
justify having that feature, and ORM metadata reverse-engineered from
the database can still be adjusted afterwards.