I created a demo entity by generating it as follows:
generate:
options:
organization: acme
package: example
entities:
seller:
configuration:
owner: user
fields:
name:
type: string
required: true
order:
type: '@Oro\Bundle\OrderBundle\Entity\Order'
Using this, data grids were generated as follows:
datagrids:
magneto-loyalty-reward-point-grid-base:
extended_entity_name: Magneto\Bundle\LoyaltyBundle\Entity\RewardPoint
type: orm
query:
select:
- e.id
- e.title
- 'o.identifier as orderTitle' # renamed the "alias: order" to "alias: o"
from:
-
table: Magneto\Bundle\LoyaltyBundle\Entity\RewardPoint
alias: e
join:
left:
- { join: e.order, alias: o } # renamed the "alias: order" to "alias: o"
The above datagrid throws the following exception:
#message: "[Syntax Error] line 0, col 53: Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression, got 'order'"
This is because "order" is a reserved keyword in MySQL. As you found, renaming the alias from "order" to "o" resolved the issue.
I agree with your suggestion that Oro Maker should update their code to avoid using "order" as an alias in queries to prevent conflicts with MySQL reserved keywords. It's always a good practice to avoid using reserved keywords or identifiers as names in your code to prevent issues like this.
I created a demo entity by generating it as follows:
Using this, data grids were generated as follows:
The above datagrid throws the following exception:
This is because "order" is a reserved keyword in MySQL. As you found, renaming the alias from "order" to "o" resolved the issue.
I agree with your suggestion that Oro Maker should update their code to avoid using "order" as an alias in queries to prevent conflicts with MySQL reserved keywords. It's always a good practice to avoid using reserved keywords or identifiers as names in your code to prevent issues like this.