-
-
Notifications
You must be signed in to change notification settings - Fork 392
DiffGenerator: fix removing schema from table name before applying regex filtering #1492
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
Conversation
054f084
to
41cb96c
Compare
0cb8736
to
a76ce4d
Compare
src/Generator/DiffGenerator.php
Outdated
if ($this->platform->supportsSchemas()) { | ||
return $name; | ||
} | ||
|
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.
After your change, I don't think the phpdoc comment is accurate anymore. Also, if the platform does not support schémas, surely the dot in a name should be interpreted literally? So... this method is no longer needed maybe?
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.
You might be right that the method might not be needed anymore.
Still, this change improves behavior for platforms that support schemas, without changing how things work for platforms that don’t — so it seems like a safe and useful step forward regardless.
Just wondering if fixing the PHPDoc alignment is the only thing holding this back. I'm also interested in this fix and would really like to see it included in the main version. |
No, it's not just PHPDoc, I'd like a definitive answer to my other comment. Please investigate whether removing this method fixes your issue without breaking anything else. |
Thanks for the clarification. I’ve just tested the diff command without the I didn’t encounter any issues — on the contrary, it now correctly excludes tables with the same name (e.g. messenger_messages) from other schemas, which is exactly what I would expect. Let me know if you'd like me to test anything else. |
I guess what would need to be tested would be a table with a dot in its name with a SQLite database, but maybe you could try opening a PR to see if removing that method passes the test suite. |
I am all good with removing the I can update this PR with the discussed changes. And will get back to you on the SQLite test. |
34c0cd7
to
f27d35e
Compare
d939ee5
to
42042b2
Compare
Congrats, green tests 🎉 Now can you please squash your 2 commits into one and improve your commit message according to the contributing guide. Make it clear why it's OK to remove the method. |
I also ran a quick test with SQLite:
// ...
$this->addSql('CREATE TABLE shop.product (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(255) NOT NULL)');
// ... Note: Without quoting
Do you think further tests are needed? By the way, I also noticed that with this change, schema_filter now works even without using a lookahead e.g. |
Thanks for testing! I think that's enough tests. Let's wait for a better commit message and merge this. |
@cristi-contiu Just checking in — since the change seems to be accepted and only the squashing and commit message update are missing, is there anything I can do to help get this over the finish line and merged into main? I'd really love to see this included. Thanks a lot! |
I guess you could provide a good commit message as a Github comment, that would be helpful. |
42042b2
to
204c89c
Compare
@greg0ire Let me know what you think. |
204c89c
to
a811ef2
Compare
It looks great, but still lacks an explanation of why it's OK to remove this method. I was the one to originally suggest that in #1492 (comment), but I was unsure, and I think it warrants a thorough investigation and a rock solid explanation. Finding the commit where it should have been removed would most certainly help. |
@greg0ire Would appending the following explanation to the existing commit message of @cristi-contiu be clear enough to address the reason for the removal?
|
Yes 👍 |
a811ef2
to
55985aa
Compare
Thanks @ddegasperi , I replaced the commit message description with the one you provided. |
@cristi-contiu please don't replace and merge both messages in one big message |
This fix prevents the DiffGenerator from stripping schemas from table names before applying the asset filter (usually a regex pattern). It aligns its behavior with the ORM's schema generator and fixes a bug on platforms without schema support, where a table name containing a dot would be incorrectly stripped of the part before the first dot. The resolveTableName() method has been removed entirely because it is no longer needed and was causing inconsistent behavior. On platforms that support schemas (e.g., PostgreSQL, SQL Server), DBAL provides qualified table names (schema.table) which should be preserved for proper filtering. On platforms that don't support schemas (e.g., MySQL, SQLite), DBAL already provides unqualified table names, making the schema stripping unnecessary. The original purpose of resolveTableName() was to handle cases where table names might contain dots on platforms without schema support, but this approach was flawed because it incorrectly assumed any dot represented a schema separator. This could break legitimate table names containing dots on platforms like SQLite. By removing this method and letting DBAL handle the platform-specific table name formatting, we achieve consistent behavior across all platforms while fixing the schema filtering issue. Testing confirms that removing this method works correctly: on schema-aware platforms, qualified names are properly filtered, and on non-schema platforms, table names are already unqualified by DBAL. Fixes doctrine#1487
55985aa
to
8517380
Compare
@greg0ire I restored the first part of the description. |
Thanks @cristi-contiu ! |
Summary
Failing test and suggested fix for #1487, requested in #1490 (review)
There are differences in the way Migrations and DBAL apply the
SchemaAssetsFilter
, usually regex: DBAL applies it on the table name (which can be qualified or unqualified, depending on platform schema support and if the table is in the default search-path schema) while Migrations always removes the schema and only applies the filter on the unqualified table name (my_table
).This fix applies the
SchemaAssetsFilter
on the table name exactly as provided by the DBAL for platforms that support schema.