-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Whilelist existing assets we know about from metadata in SchemaTool::getUpdateSchemaSql() #7875
Conversation
86c4ba2
to
40aa43f
Compare
I understand the problem and how it manifests itself to the end user. I've been running in to this in Symfony with the messenger tables. Kudos to you for taking a stab at fixing it. I always felt like the filter functionality was sort of half baked. Can you think of any better way we could implement this to eliminate the nested closures? |
Passing But that's an API change so it's out of reach for a bug fix on the ORM side. |
562288a
to
2abffee
Compare
Now with tests, courtesy of @l-vo, big thanks to him! |
3541007
to
ae645f0
Compare
Looks good to me. As for the nested closures, there isn't much we can do since DBAL only takes a single closure as a filter. If you want to expand on that filter later on, there's no other option than to wrap it. In one of our bundles we have a chain to take care of that, but DBAL itself does not provide any helpers for this purpose. Introducing a chain filter class would require this to go into 2.7 as it's a new API, so I'm ok with keeping the nested closures and treating this as a (long-awaited) bug fix in 2.6. |
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.
LGTM - discussed directly with @nicolas-grekas, and the use-case seems clear to me now 👍
What I'm still puzzled on is BC compliance of this patch: we're now allowing the schema diffing to kick in for known symbols, which may break existing use-cases (where mappings were kept only as documentation, never really used by the ORM). @doctrine/doctrinecore ideas? |
It is definitely a "BC Break" but I am not sure in what ways it would manifest itself in desirable ways that someone would depend on, but who knows. In the problem Symfony team is trying to fix, the resulting SQL we produce just has to be manually edited by the developer before reviewing and executing to remove the tables that shouldn't be there. |
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.
Just some small changes, we should be good to go soon.
tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php
Outdated
Show resolved
Hide resolved
I'll plan this for |
0b59f2a
0b59f2a
to
6e7c39e
Compare
Comments addressed @lcobucci |
6e7c39e
to
580f8fb
Compare
@lcobucci 2.7.1 sounds good, as does mentioning this in UPGRADE.md. I've pushed a commit to do this. Thanks @nicolas-grekas! |
2784bf5
to
50fc3d8
Compare
50fc3d8
to
f27bc18
Compare
0b5aaaf
to
0a3a08d
Compare
…getUpdateSchemaSql()
0a3a08d
to
351fc63
Compare
351fc63
to
0ce1440
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.
I've unified and simplified the test case too, LGTM.
Thanks @nicolas-grekas and @l-vo!
@greg0ire why is this not merged in master? |
@mvorisek because the last merge up to master is a few years old. |
This PR is a sidekick of doctrine/DoctrineBundle#1037
When generating schema diffs, if a source table is filtered out by a
schema_filter
expression, then aCREATE TABLE
is always generated, even if the table already exists.This PR makes
SchemaTool::getUpdateSchemaSql()
whitelist tables that are listed in the metadata we are generating the diff for, thus fixing the issue.