Skip to content

test(DbHandler): make sure auto-increment is reset in between tests#58501

Draft
joshtrichards wants to merge 2 commits intomasterfrom
jtr/test-dbhandler-truncate-teardown
Draft

test(DbHandler): make sure auto-increment is reset in between tests#58501
joshtrichards wants to merge 2 commits intomasterfrom
jtr/test-dbhandler-truncate-teardown

Conversation

@joshtrichards
Copy link
Copy Markdown
Member

@joshtrichards joshtrichards commented Feb 21, 2026

DELETE doesn't reset auto-increment; TRUNCATE does. Also probably faster.

  • Resolves: #

Summary

We're doing DELETE rather than TRUNCATE in tearDown(). The former does not reset auto-increment/identity columns on MySQL. Random failures like below with MySQL may be because of this.

Would not be caught in setUp() by the assert on select() because that's based on count not id.

There was 1 failure:

1) OCA\Federation\Tests\DbHandlerTest::testRemove
Failed asserting that 5 is identical to 0.

/home/runner/actions-runner/_work/server/server/apps/federation/tests/DbHandlerTest.php:95

P.S. Though I'm discovering from looking at DBAL's code that even though DBAL implements getTruncateTableSQL() for all supported databases, it merely does a DELETE in SQLite... so we may need a wrapper function or something to truly take care of this universally across our tests (since I suspect we have other tests want to do real TRUNCATE/equivalents in).

TODO

  • ...

Checklist

DELETE doesn't reset auto-increment; TRUNCATE does. Also probably faster.

Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added 2. developing Work in progress tests Related to tests feature: database Database related DB labels Feb 21, 2026
Signed-off-by: Josh <josh.t.richards@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress feature: database Database related DB tests Related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant