Skip to content

Fix flaky testCreateTableIndexWithWhere position lookup#1085

Merged
LordSimal merged 1 commit into5.xfrom
fix-sqlite-index-where-test
May 10, 2026
Merged

Fix flaky testCreateTableIndexWithWhere position lookup#1085
LordSimal merged 1 commit into5.xfrom
fix-sqlite-index-where-test

Conversation

@dereuromark
Copy link
Copy Markdown
Member

Summary

The test was hardcoding $queries[2] to pluck the CREATE UNIQUE INDEX statement out of the dry-run message buffer. The buffer now contains a handful of phinxlog setup messages before the create-index call:

[1] DROP TABLE "phinxlog";
[2] ALTER TABLE "tmp_phinxlog" RENAME TO "phinxlog";
[3] INSERT INTO "tmp_phinxlog"() SELECT  FROM "phinxlog";
[4] DROP TABLE "phinxlog";
[5] ALTER TABLE "tmp_phinxlog" RENAME TO "phinxlog";
[6] CREATE TABLE "table1" (...);
[7] CREATE UNIQUE INDEX "table1_email_index" ON "table1" (...) WHERE is_verified = true;

So the test was failing locally with the assertion message:

Failed asserting that 'ALTER TABLE "tmp_phinxlog" RENAME TO "phinxlog";' contains "CREATE UNIQUE INDEX "table1_email_index"".

Found while reducing the PHPStan baseline in #1083; the failure is pre-existing and reproducible on master.

Fix

Walk the message buffer and pick the matching query rather than indexing by position. The two assertions on the index DDL contents are unchanged.

The test was hardcoding queries[2] to find the CREATE UNIQUE INDEX
output. The dryrun message buffer now contains additional phinxlog
setup messages before the create-index call, so the position drifted
and the test failed locally. Look the query up by its expected prefix
instead, which makes the test robust to ordering changes around it.
@dereuromark dereuromark added the bug label May 9, 2026
@LordSimal LordSimal merged commit 9fc2d25 into 5.x May 10, 2026
14 checks passed
@LordSimal LordSimal deleted the fix-sqlite-index-where-test branch May 10, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants