mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-134: Allow user-defined DQL builds #169
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Nov 9, 2009).
Originally assigned to: @guilhermeblanco on GitHub.
Jira issue originally created by user @guilhermeblanco:
We should allow a more flexible DQL system by enabling user defined grammars.
One good example is if the user wants to create several functions that are converted to custom queries.
Example: getUsers() => SELECT * FROM users u
Currently it's impossible because our QueryLanguage does not support that.
What should be done:
1- Create a chain of custom DQL support, so people can include multiple custom support
2- Update the method: Doctrine\ORM\Query\Parser::QueryLanguage, specially the default: clause to inspect for possible user defined support and forward to it.
If none of the chains (or there's no custom support), throw exception normally.
In the suggested situation, that would require the implementation of this grammar by user:
QueryLanguage ::= identifier "(" {FunctionParameter {"," FunctionParameter}}* ")"
FunctionParameter ::= Literal | InputParameter
Literal and InputParameter inherited from DQL parser.
That would convert to something like an SELECT statement. In the specific case of getUsers, it'll return a SELECT statement.
It's just one example of possible implementation inside DQL.
Another one could be something like:
CREATE User (property1="value", property2="value")
Which would launch an INSERT statement to Database.
In this second example, if correctly defined the grammar, we could support insertion of Entities via custom user support DQL.