Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Apparently we are missing a test to confirm a table can be truncated while a transaction is open. At least, i could not find one.
Proposed resolution
Add one.
Remaining tasks
Review patch.
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff_9-13.txt | 5.94 KB | mondrake |
#13 | 2868273-13.patch | 4.49 KB | mondrake |
Comments
Comment #2
mondrakeComment #3
mondrakeLet's also test that truncate is still OK after closing the transaction, and add a test where the transaction is rolled back.
Comment #4
mondrakeComment #6
mondrakeThis should be better...
Comment #8
mondrakeOops
Comment #9
mondrakeMarking the tests skipped if the db driver does not support transactions.
Comment #12
borisson_This test is great, it adds coverage that we are missing.
db_truncate is deprecated, so instead of testing db_truncate, we should test
\Drupal\Core\Database\Connection::truncate()
instead.Comment #13
mondrakeThanks for review @borisson_!
Actually, all
db_*
functions are deprecated, so let's at least avoid introducing new usages. Also, as a db abstraction fan, I prefer to avoid usage ofConnection::query
on behalf ofConnection::select
as much as possible.Comment #14
borisson_Looks solid. Yay for more tests!
Comment #15
mondrakeIt might be worthwhile to move this hunk to the
DatabaseTestBase
parent class, so that all the test subclasses could replace calls todb_*
function with$this->connection->*()
calls instead of the\Drupal::database()->*
calls that I see are being suggested in the issues that are removing usage of deprecateddb_*
functions. Some core committer feedback would help, this could also be a followup if deemed relevant.Comment #16
alexpottAdding credit to @borisson_ for spotting the deprecated usage.
Comment #17
alexpottCommitted and pushed b23ee08a0d to 8.6.x and 826573683f to 8.5.x. Thanks!
Backported to 8.5.x since this is test coverage only.
Comment #20
mondrakeThanks @alexpott, any comment re. #15?
Comment #21
alexpott@mondrake makes sense +1
Comment #22
mondrakeOpened #2953385: Add a $connection property to DatabaseTestBase kernel test class to be used by extending classes