nova-chartjs
nova-chartjs copied to clipboard
[BUG] Query with apostrophe throws a MySQL statement error
Describe the bug
I'm using a StackedChart
chart type and one of my series has an apostrophe. When I'm trying to render the chart, I receive a MySQL statement error from the TotalRecordsController
that says "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 's' then 1 else 0 end) as 'Macy's' ..."
To Reproduce
$this->title('Order Ingestion');
$this->model(Order::class);
$this->options([
'uom' => 'day',
'showTotal' => false,
'latestData' => self::HISTORY_DAYS,
]);
$this->series([[
'label' => 'Macy\'s',
'filter' => [
'key' => 'customer_type',
'value' => 'Macy\'s'
],
'backgroundColor' => '#5e4fa2',
]]
);
Expected behavior
A rendered chart like
Dependencies Version (please complete the following information):
- Laravel Version: 8.83.27
- Nova Version: 4.20.2
- Nova-ChartJS Version: 0.4.0
Desktop (please complete the following information):
- OS: macOS Ventura 13.4
- Browser Chrome
- Version 114.0.5735.198
I pushed a fix here: https://github.com/coroo/nova-chartjs/pull/162