Table Summarizer Bug on PostgreSQL

So I have a table column defined as such:

Tables\Columns\TextColumn::make('price')
        ->money()
        // Old simple way
    // ->summarize(Sum::make()->money()->label('Total Price')),
    // New Way with custom query
    ->summarize(
        Summarizer::make()
            ->label('Total')
            ->money()
            ->using(fn (\Illuminate\Database\Query\Builder $query) => $query->sum(DB::raw('price * quantity'))),


I had asked yesterday how do to this price * quantity calculation but I was getting this error:
SQLSTATE[42601]: Syntax error: 7 ERROR: zero-length delimited identifier at or near """"


The query that is generated is
SELECT
  sum(price * quantity) AS aggregate
FROM
  (
    SELECT
      "line_items".*
    FROM
      "line_items"
      INNER JOIN "invoices" ON "invoices"."id" = "line_items"."invoice_id"
    WHERE
      "invoices"."requisition_id" = 1
  ) AS ""


Clearly it's the last line
) AS ""
. I dug into the
Summarizer.php
file on line 108.

$query = DB::table($query->toBase());

I haven't really looked at the source code for any of the Filament query stuff before it I changed the line to
$query = DB::table($query->toBase(), 'test');


The above code now works. I'm not saying the table alias needs to be 'test' but I just needed a name to try. I'm not really sure what the best practice (naming) for this would be but I might also cross post this as a GitHub issue.

Just wasn't sure if there was something else on the 'user' side (me, the dev) that I need to do to get this working? (since it also seems like a postgres quirk)
Was this page helpful?