Skip to content

test: assert routines are created before the views and triggers that call them - #194

Merged
jasdeepkhalsa merged 1 commit into
masterfrom
claude/routine-ordering-test
Aug 24, 2026
Merged

jasdeepkhalsa merged 1 commit into
masterfrom
claude/routine-ordering-test

Conversation

@jasdeepkhalsa

Copy link
Copy Markdown
Member

Why

The routine-ordering fix shipped in 3.0.0-rc.9 (#192) with no test of its own.

It was covered only incidentally — by a partition-trigger test that happens to need a function to exist. So a regression would have failed pointing at triggers rather than at ordering, and only on the Postgres legs. That is the kind of coverage that looks fine on a green run and misleads you on a red one.

I found this auditing my own work rather than from a failure, which is the better time to find it.

The bug it guards

CreateRoutine used to sort last, after CreateView and CreateTrigger, so a trigger whose function was also new was emitted before the function existed:

CREATE TRIGGER tg AFTER INSERT ON public.t ... EXECUTE FUNCTION f();
CREATE OR REPLACE FUNCTION public.f() ...
ERROR: function f() does not exist

Views have the same dependency, so both are asserted.

It earns its place

Verified the test actually fails without the fix rather than assuming it:

# DiffSorter reverted to the previous order
Failed asserting that 2 is less than 0.
FAILURES! Tests: 1, Assertions: 1, Failures: 1.

# fix restored
OK (21 tests, 35 assertions)

Also

The docblock on testUpOrderDropsProgrammableBeforeTables still described CreateRoutine as part of the trailing group with CreateView and CreateTrigger — which stopped being true when the fix landed. Stale comments that contradict behaviour are worse than none, so it now points at the new test.

Postgres suite 47 tests / 139 assertions; unit + SQLite 334 tests.

🤖 Generated with Claude Code

…call them

The ordering fix shipped in 3.0.0-rc.9 with no test of its own. It was covered
only incidentally, by a partition-trigger test that happens to need a function
to exist — so a regression would have failed pointing at triggers rather than
at ordering, and only on the Postgres legs.

Confirmed the test earns its place: reverting DiffSorter to the previous order
fails it with "Failed asserting that 2 is less than 0", and restoring the fix
passes.

The docblock above testUpOrderDropsProgrammableBeforeTables still described
CreateRoutine as part of the trailing group with CreateView and CreateTrigger,
which stopped being true when the fix landed. Corrected, with a pointer to the
new test.

Postgres suite 47 tests; unit + SQLite 333 tests.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added bug php Pull requests that update php code postgres Related to Postgres sqlite Related to Sqlite labels Aug 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

@jasdeepkhalsa
jasdeepkhalsa merged commit 3859a33 into master Aug 24, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug php Pull requests that update php code postgres Related to Postgres sqlite Related to Sqlite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant