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

json column as dateColumn not working #71

Open
saifulapm opened this issue Aug 9, 2024 · 2 comments
Open

json column as dateColumn not working #71

saifulapm opened this issue Aug 9, 2024 · 2 comments

Comments

@saifulapm
Copy link

Hi, I am getting error when I am trying to use json column as dateColumn.

        $trendQuery = Trend::query($chartQuery)
            ->between(
                start: $startDate,
                end: $endDate,
            )
            ->dateColumn('custom_data->assigned_at');

Here custom_data is a json field. Getting this error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'assigned_at, '%Y-%m-%d') as date, count(*) as aggregate ' at line 2

select 
                date_format(custom_data->assigned_at, '%Y-%m-%d') as date,
                count(*) as aggregate
             from `items` where `user_id` = 296 and json_unquote(json_extract(`custom_data`, '$."assigned_at"')) between 2024-08-01 00:00:00 and 2024-08-31 23:59:59 group by `date` order by `date` asc
@sezohessen
Copy link

Same

@sezohessen
Copy link

Maybe try

->dateColumn('JSON_EXTRACT(custom_data, "$. assigned_at")')

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

2 participants