Flowframe / laravel-trend

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

Prevents ambiguous date column when providing a JOIN query #30

Open LorensoD opened 1 year ago

LorensoD commented 1 year ago

As suggested in #18 by @ArnoudLier it would be great if the table name of the queried model could be prefixed to the date column.

This prevents ambiguous column exceptions (like the one below) when providing a JOIN query.

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in field list is ambiguous
ceejayoz commented 1 year ago

You should already be able to resolve this by calling ->dateColumn('foo.created_at') on your Trend.

LorensoD commented 1 year ago

Thanks for the tip @ceejayoz! I didn't realise that.

But since I use a lot of joins in one of my projects I would still love it if the models table name is automatically prepended to the date column. That would make it just a bit cleaner and make joins work out of the box.