Skip to content

Conversation

@m41denx
Copy link
Contributor

@m41denx m41denx commented Oct 31, 2025

When searching servers in admin area a SQL error is thrown:

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'name'
in WHERE is ambiguous (Connection: mariadb, 
SQL: select count(*) as aggregate from `servers` left join `nodes` on `servers`.`node_id` = `nodes`.`id` 
where `node_id` in (1) and (
    `name` like %ddfj% 
    or exists (select * from `eggs` where `servers`.`egg_id` = `eggs`.`id` and `name` like %ddfj%) 
    or exists (select * from `users` where `servers`.`owner_id` = `users`.`id` and `username` like %ddfj%)
)) 
(View: /var/www/pelican/vendor/filament/tables/resources/views/index.blade.php) 
(View: /var/www/pelican/vendor/filament/tables/resources/views/index.blade.php)

This commit fixes described issue

@coderabbitai
Copy link

coderabbitai bot commented Oct 31, 2025

📝 Walkthrough

Walkthrough

Added import of the Builder class and enhanced the search functionality for the 'name' column in the ListServers page. The search now uses a fully-qualified column reference with a LIKE comparison instead of relying on default search logic.

Changes

Cohort / File(s) Summary
Name column search enhancement
app/Filament/Admin/Resources/Servers/Pages/ListServers.php
Added Illuminate\Database\Eloquent\Builder import. Modified the 'name' column search to use a custom query that explicitly filters on the fully-qualified 'name' column via LIKE comparison instead of default search behavior.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Fix admin serverlist search" directly relates to the main change in the changeset. The code modification addresses a SQL error that occurs when searching servers in the admin interface by fixing an ambiguous column reference in the search query. The title is concise, clear, and specific enough for a developer scanning the repository history to understand that this change addresses a search functionality bug in the admin server list.
Description Check ✅ Passed The pull request description is clearly related to the changeset and provides meaningful context. It describes the specific SQL error (integrity constraint violation with ambiguous 'name' column) that occurs when searching in the admin server list, includes the failing query, and states that the commit fixes this issue. This directly corresponds to the code change that customizes the search behavior for the 'name' column to use a fully-qualified reference, resolving the ambiguity.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/Filament/Admin/Resources/Servers/Pages/ListServers.php (1)

51-53: Correctly fixes the ambiguous column name error.

The custom search query properly disambiguates the name column by using a fully-qualified reference, which resolves the SQL error when the servers table is joined with nodes.

For a minor optimization, consider using $query->qualifyColumn('name') instead of Server::query()->qualifyColumn('name'), since $query is already scoped to the Server model:

-                    ->searchable(query: fn (Builder $query, string $search) => $query->where(
-                        Server::query()->qualifyColumn('name'), 'like', "%{$search}%")
+                    ->searchable(query: fn (Builder $query, string $search) => $query->where(
+                        $query->qualifyColumn('name'), 'like', "%{$search}%")
                    )

This avoids creating a new query instance just to retrieve the qualified column name.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6aa76e and 859daa7.

📒 Files selected for processing (1)
  • app/Filament/Admin/Resources/Servers/Pages/ListServers.php (2 hunks)
🔇 Additional comments (1)
app/Filament/Admin/Resources/Servers/Pages/ListServers.php (1)

19-19: LGTM! Necessary import for the custom search query.

The Builder import is required for the type hint in the custom searchable query closure below.

@notAreYouScared notAreYouScared merged commit b2aff54 into pelican-dev:main Nov 3, 2025
25 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants