Closed ArnaudLier closed 1 year ago
Can be fixed like this (this code is very bad but it's a quick workaround):
public function aggregate(string $column, string $aggregate): Collection { $values = $this->builder ->toBase() ->selectRaw(" {$this->getSqlDate()} as date, {$aggregate}({$column}) as aggregate ") - ->whereBetween($this->dateColumn, [$this->start, $this->end]) + ->whereBetween($this->builder->getModel()->getTable() . '.' . $this->dateColumn, [$this->start, $this->end]) ->groupBy('date') ->orderBy('date') ->get(); return $this->mapValuesToDates($values); }
protected function getSqlDate(): string { $adapter = match ($this->builder->getConnection()->getDriverName()) { 'mysql' => new MySqlAdapter(), 'sqlite' => new SqliteAdapter(), 'pgsql' => new PgsqlAdapter(), default => throw new Error('Unsupported database driver.'), }; - return $adapter->format($this->dateColumn, $this->interval); + return $adapter->format($this->builder->getModel()->getTable() . '.' . $this->dateColumn, $this->interval); }
Closing stale issue
Can be fixed like this (this code is very bad but it's a quick workaround):