LaravelDaily/laravel-charts

Column not found

skillcraft-io opened this issue · 3 comments

The Condition on Line Charts does not seem to be working properly...

.. 'chart_type' => 'line', 'conditions' => [ ['name' => 'Condition 1', 'condition' => 'field = value', 'color' => 'black'], ['name' => 'Condition 2', 'condition' => 'field2 = value2', 'color' => 'blue'], ], ...
However the code is generating a error:

Column not found: 1054 Unknown column 'value' in 'where clause' (SQL: select * from tablewherecreated_at>= 2020-06-07 and field = value)

I am using the version 0.1.20 and the latest Laravel Version.

Please advise.

@zhxscript it wasn't intended to work like you're trying it. You need to provide static raw query with all values you need, so value should be probably in "value" or something.

The way you used it, the package understands value as a DB column.

Figured it out... after looking at what I was doing, realized my error...

I had to update my condition to wrap my value in single quotes.

'conditions' => [ ['name' => 'Condition', 'condition' => "field = 'value'", 'color' => 'black'], ['name' => 'Condition 2', 'condition' => "field2 = 'field2'", 'color' => 'blue'], ],

Figured it out... after looking at what I was doing, realized my error...

I had to update my condition to wrap my value in single quotes.

'conditions' => [ ['name' => 'Condition', 'condition' => "field = 'value'", 'color' => 'black'], ['name' => 'Condition 2', 'condition' => "field2 = 'field2'", 'color' => 'blue'], ],

Thanks for this. It save me a lot of time