Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict between date and created_at column #68

Open
simonelepore opened this issue Jul 5, 2024 · 3 comments
Open

Conflict between date and created_at column #68

simonelepore opened this issue Jul 5, 2024 · 3 comments

Comments

@simonelepore
Copy link

simonelepore commented Jul 5, 2024

In two of my projects I've had the same issue. If I have a table with both a 'date' column and the default 'created_at' column, the Trend query will not work. I think it's because the alias 'date' that is internally used in the query conflicts with the actual other 'date' column (when it performs a group by and order by 'date').

In fact, if I change name to the 'date' column to something else, it will work. Or if I set the mysql 'strict' property to false in database.php

Is there a way to fix this? thank you!

@FortuneV13
Copy link

I can confirm the same issue here.

@simonelepore
Copy link
Author

simonelepore commented Jul 12, 2024

I also discovered something else.. if you use Trend::query (to chain where's etc., instead of Trend::model) while you have both a created_at and date column (and 'strict' property to false), the results of the trend will be completely messed up 😅

plus, I discovered that it is generally not a good idea to turn that property to false

@agumaxwellforcode
Copy link

agumaxwellforcode commented Sep 16, 2024

If you still have this problem, just pass a custom dateAlias parameter.

->dateAlias($custom_date_alias)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants