Flowframe / laravel-trend

Generate trends for your models. Easily generate charts or reports.
MIT License
671 stars 70 forks source link

Problem with "kirschbaum-development/eloquent-power-joins" package #15

Closed aldesrahim closed 1 year ago

aldesrahim commented 2 years ago

Hi, I have notice when using eloquent-power-joins can cause query problem.

So, eloquent-power-joins is using scope to simplify join query between relations, please take a look at this particular line of codes. If you notice, it will check if query has select, if not it will add SELECT * to query.

Since laravel-trend's aggregate method using selectRaw, the code I've shown (line 40) will return false, and add SELECT * to query, it cause problem since laravel-trend using groupBy to find aggregate columns.

I have solution for this problem by replacing this with this:

->select([
    DB::raw("{$this->getSqlDate()} as date"),
    DB::raw("{$aggregate}({$column}) as aggregate"),
])

I am sorry for my bad english, I hope you all can understand what I am trying to say. Thank you !

Info: Laravel 9, MySQL

Larsklopstra commented 1 year ago

Closing stale issue