doctrine / data-fixtures

Doctrine2 ORM Data Fixtures Extensions
http://www.doctrine-project.org
MIT License
2.78k stars 224 forks source link

Use single query truncate when possible #314

Closed goetas closed 4 years ago

goetas commented 5 years ago

Hi, this PR allows to truncate multiple tables with a single query when supported (postgres as example).

I'm pretty sure that is not really elegant, but it allowed us to have a test suite running in ~20s instead of 6m. I'm open for suggestions on how to improve it.

It would be nice to have getTruncateTableSQL allowing an array as table name...

Did not write tests yet as I'm not sure that the current version is good and that will be considered at all for merging.

Feedback?

goetas commented 5 years ago

A first idea could be to add isMultiTableTrucateSupported() and relative methods in the DBAL package.

alcaeus commented 5 years ago

This should definitely be solved in DBAL. Since that will take time (and may even require a BC break to have getTruncateTableSQL accept an array), it may be worth working around this restriction here for now. Other opinions @doctrine/doctrinecore?

ostrolucky commented 5 years ago

I share same opinion

goetas commented 5 years ago

and may even require a BC break to have getTruncateTableSQL accept an array

Would be considered a BC break adding to the AbstractPlatform class a new method getTruncateMultiTableSQL ?

alcaeus commented 5 years ago

Would be considered a BC break adding to the AbstractPlatform class a new method getTruncateMultiTableSQL ?

As long as the method isn't abstract, I don't see a problem with that.

goetas commented 5 years ago

Will start with a PR there then!

greg0ire commented 4 years ago

I'm closing, but tell me if I need to reopen this.