Closed jgxvx closed 4 years ago
@stephen-lewis can you please have a look at this?
Apologies @jgxvx I didn't look deeply enough on this originally.
@greg0ire: PR created to fix; essentially it reverts the changes to getTableName
and adds a function like getTruncateTableSQL
to get the delete SQL statement. I've mimicked the code in orm's SchemaTool.
--edit: grammar
Thank you, @stephen-lewis!
And thank you @jgxvx , I rarely see such precise bug reports!
Can anyone experiencing this please test #340 ? Instructions are here: https://github.com/doctrine/data-fixtures/pull/340#issuecomment-574851931
We have an entity called
Order
, which is a reserved keyword. We use MySQL in production and SQLite to run integration tests. We never had any issues using this configuration:Using the default quoting strategy (
Doctrine\ORM\Mapping\DefaultQuoteStrategy
) a table name ofacme_shop__order
is generated for SQLite.Starting with doctrine/data-fixtures v1.4.1 this project's build fails when trying to purge the schema:
Last Working Version 1.4.0
Breaking Version 1.4.1
Breaking Commit 7f309a20f803c490638ffb7e1c48b25c4aeb2f82
Breaking Pull Request
334
Problem Up to v1.4.0,
ORMPurger::getTableName()
would use the configured quoting strategy to generate the table name. Which seems like the sensible thing to do. The method would return the correct table nameacme_shop__order
. The string "acme_shop__order" is not an SQLite keyword.Starting with v1.4.1,
ORMPurger::getTableName()
disregards any and all configured strategies and callsgetQuotedName()
on an instance ofDoctrine\DBAL\Schema\Identifier
, returning a table name ofacme_shop."order"
, which may or may not be a valid SQLite table name, but is not the same as the one created by the strategy.This table name is later passed to
SqlitePlatform::getTruncateTableSQL()
which replaces the.
with a__
, resulting in the final table nameacme_shop__"order"
which is used in the executed SQL statement.Output of schema tool:
Expected Purger generates same table names as schema tool.
Actual Purger (in cooperation with SqlitePlatform) generates invalid table names, containing unnecessary quotings, leading to errors when trying to purge data in previously created schema. This behaviour breaks existing code when moving from doctrine/data-fixtures 1.4.0 to 1.4.1.