Skip to content

fix: qualify the index list's search columns - #26

Merged
Heyosseus merged 1 commit into
Heyosseus:mainfrom
wit3:fix/index-search-ambiguous-relname
Sep 21, 2026
Merged

Heyosseus merged 1 commit into
Heyosseus:mainfrom
wit3:fix/index-search-ambiguous-relname

Conversation

@wit3

@wit3 wit3 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #25.

Searching the Indexes list threw SQLSTATE[42702]: column reference "relname" is ambiguous and took the whole page down with it. getEloquentQuery() joins pg_class, which has a relname of its own, while the column's search columns were unqualified:

->searchable(['indexrelname', 'relname'])

Filament leaves a search column alone unless it is already prefixed with the model's table, so what reached PostgreSQL was lower("relname"::text) like $1 with two candidate relations in scope. indexrelname exists in only one of them, which is why the error named just the one column.

Qualifying both is enough, and reads the way the rest of the resource already selects its columns:

->searchable(['pg_stat_user_indexes.indexrelname', 'pg_stat_user_indexes.relname'])

The regression test drives the column's own search constraint against real SQL rather than a rendered page, so it fails with the QueryException on main and covers both searches the column offers — by index name, and by the table the index belongs to.

Verified

  • composer test:lint and composer test:refacto pass.
  • tests/Filament/IndexResourceTest.php passes in full (5 tests, 21 assertions); the new test fails with SQLSTATE[42702] without the one-line change.
  • The rest of the suite was run on a PostgreSQL without pg_stat_statements preloaded (no Docker on this machine), so the Statements, Learn and History tests fail there on SQLSTATE[55000] ... must be loaded via shared_preload_libraries, before and after this change alike. composer test:types reports 10 pre-existing view-string errors under src/Http/Controllers, untouched by this change — CI will be the judge of both.

🤖 Generated with Claude Code

The Indexes list joins pg_class onto pg_stat_user_indexes, and both of them
have a relname. The search columns were unqualified, so the predicate Filament
built named a column PostgreSQL could not resolve, and every search on that
page ended in SQLSTATE[42702] rather than a result.

Qualifying both with the model's table is enough -- Filament passes a column
already prefixed with it through untouched -- and it keeps the column's two
searches, by index name and by the table the index belongs to, working as they
read.

Fixes Heyosseus#25

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@wit3

wit3 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

The six red legs here are not this change: they all fail at composer test:types, on the ten pre-existing expects view-string, string given errors under src/Filament/Widgets and src/Http/Controllers. main at ca2a86c, untouched, fails exactly the same way — larastan resolves to 3.12.2, published after the last green run, and the package's vacuum:: views cannot be resolved statically. Filed separately as #27 so the two don't get tangled.

The three green legs (PG 14/15/16) are the SQL-only ones; the full gate never gets past PHPStan to the tests on the others. Locally, with that step aside: test:lint and test:refacto pass, and tests/Filament/IndexResourceTest.php is green in full — the new test fails with SQLSTATE[42702] without the one-line change and passes with it.

@Heyosseus
Heyosseus merged commit fc0ab6c into Heyosseus:main Sep 21, 2026
3 of 9 checks passed
@wit3

wit3 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the quick merge and the release — one snag, though: v1.2.1 does not contain this change.

The tag points at 80023da ("fix: let static analysis see the package's own view namespace", 11:53:30Z), whose parent is the old ca2a86c. This PR landed in fc0ab6c at 12:07:54Z, fourteen minutes after the commit that got tagged. So the release notes describe both halves, but the tarball carries only the larastan one:

$ gh api "repos/Heyosseus/vacuum/contents/src/Filament/Resources/IndexResource.php?ref=v1.2.1" --jq .content | base64 -d | grep searchable
                    ->searchable(['indexrelname', 'relname'])

$ gh api "repos/Heyosseus/vacuum/contents/src/Filament/Resources/IndexResource.php?ref=main" --jq .content | base64 -d | grep searchable
                    ->searchable(['pg_stat_user_indexes.indexrelname', 'pg_stat_user_indexes.relname'])

A v1.2.2 off current main would sort it. Moving the existing tag would too, but Packagist has already cached v1.2.1 at that reference, so anyone who installed it keeps the old file — a new patch tag is the honest fix.

No rush from my side: we are holding our bump until it is out rather than shipping 1.2.1, since its only change is contributor-facing.

@Heyosseus

Copy link
Copy Markdown
Owner

Sorry, my bad. Check out v1.2.2 release. Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Searching the Indexes list throws SQLSTATE[42702]: column reference "relname" is ambiguous

2 participants