DDC-134: Allow user-defined DQL builds #169

Open
opened 2026-01-22 12:29:24 +01:00 by admin · 0 comments
Owner

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.

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.
admin added the New Feature label 2026-01-22 12:29:24 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#169