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

If I use AS inside SQL and with Space, it will throw syntax error #12

Open
pyyick opened this issue May 30, 2018 · 1 comment
Open

If I use AS inside SQL and with Space, it will throw syntax error #12

pyyick opened this issue May 30, 2018 · 1 comment

Comments

@pyyick
Copy link

pyyick commented May 30, 2018

The following SQL is OK:

 SELECT `increment_id` AS 'Order_ID' FROM `sales_order_grid``

However this one will throw SQL syntax error:

 SELECT `increment_id` AS 'Order ID' FROM `sales_order_grid``

After I drill on var/log/system.log, I found the the resultant SQL is the cause of this error.

SELECT `t`.* FROM (SELECT `increment_id` AS 'Order ID' FROM `sales_order_grid`) AS `t` ORDER BY Order ID DESC LIMIT 20
@nacho2706
Copy link

Yeah, that's an issue on the extension.
You can edit the file: Block/Adminhtml/Report/Grid.php in the function addColumnSet($dataItem)

In that file you can modify the line 57:
$data = [
'data' => ['header' => $key,
'index' => $key,
'type' => 'text']
];

for:

$data = [
'data' => ['header' => str_replace("_"," ",$key),
'index' => $key,
'type' => 'text']
];

In that way, you can set the query with the "_" but the backend grid column title will show the right space between the words.

Let me know if you have any questions.

Best,

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