nova-chartjs icon indicating copy to clipboard operation
nova-chartjs copied to clipboard

[BUG] Query with apostrophe throws a MySQL statement error

Open adrianmihaila opened this issue 1 year ago • 1 comments

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 Screenshot 2023-07-13 at 09 30 24

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

adrianmihaila avatar Jul 13 '23 06:07 adrianmihaila

I pushed a fix here: https://github.com/coroo/nova-chartjs/pull/162

adrianmihaila avatar Jul 13 '23 06:07 adrianmihaila