markshust/magento2-module-ordergrid

MySQL error, when Order Date filter is applied

dmitriy-yermolayev opened this issue · 1 comments

When Order Date filter is applied the following error occurs:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous, query was: SELECT main_table.* FROM sales_order_gridASmain_tableINNER JOINsales_order_item ON main_table.entity_id = sales_order_item.order_id WHERE (((created_at >= '2023-02-01 05:00:00'))) AND (((created_at<= '2023-02-08 04:59:59'))) GROUP BYmain_table.entity_id ORDER BY main_table.created_at DESC LIMIT 20

As created_at exists in both sales_order and sales_order_grid, and created_at is not prefixed with main_table. the query is ambiguous.

Appreciate the bug report! This should be fixed in 35c5f38

Not exactly sure what was going on, but the removed code appears to be legacy code from a previous version of M2 that is no longer needed. Simply removing it seemed to do the trick.

This was fixed in version 1.1.1 which was just published. If this causes any errors, just let me know.