Open GekkeGlennDev opened 2 months ago
@GekkeGlennDev Hi! You can check here why this happens https://github.com/filamentphp/filament/issues/12403#issuecomment-2071583041 in your case you need to change your code to
// This cause the SQL error:
->summarize(Tables\Columns\Summarizers\Sum::make()->using(
fn(Builder $builder) => $this->getOwnerRecord()->products()->sum('products.price')
))
Thank you @dmitry-udod for a solution that may work for now, I only had to change the name of the column of sum to order_product.price
because I needed the pivot table.
But I see this as a quick fix and think it should not be the case for a default flow when using many-to-many with pivot columns. But that is my opinion.
At least thanks for a fix!
@GekkeGlennDev No problem. Yeah, I agree with you that this is a quick fix, not a solution.
Workaround for this very specific case implemented in #12821
@danharrin Thank you for your effort.
I have updated the Reproduction repository to the newest version of the filament v3 package (v3.2.83) But Unfortunately the issue is still happening.
@GekkeGlennDev I have not released the PR yet
Apologies, ignore me, I will have a look this week
Hay @danharrin did you already looked into this issue?
Package
filament/filament
Package Version
v3.2.71
Laravel Version
v11.4.0
Livewire Version
v3.4.10
PHP Version
v8.3.6
Problem description
In a RelationshipManager::table() I defined some columns to display on the detail page of the parent model. Now, there are some numbers in it for knowing the amount of a product.
When I call
->summarize(Sum::make())
on a numeric column, it throws the SQL Exception:SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'id'
Expected behavior
Instead of throwing a SQL Exception, I should get the summarized amount of all the entries in that table.
Steps to reproduce
php artisan make:filament-resource OrderResource -G
php artisan make:filament-relation-manager OrderResource products title
->summerize()
on the numeric column.Reproduction repository
https://github.com/GekkeGlennDev/filament-sql-issue
Relevant log output
Donate 💰 to fund this issue