[PR #717] Allow query parameters starting with an underscore #8605

Closed
opened 2026-01-22 16:00:43 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/717

State: closed
Merged: Yes


Using a query parameter of which the name starts with an underscore results in a QueryException. For example:

$q = $em->createQueryBuilder()
    ->select("u")
    ->from("User", "u")
    ->where("u.username = :_name")
    ->setParameter("_name", "bar")
    ->getQuery();

Results in:

Invalid parameter format, : given, but :<name> or ?<num> expected.

This happens because of a bug in the Lexer, which recognizes :_name as two tokens (the : as the start of a input parameter, _name as an identifier). The attached patch changes the regular expression for input parameters to allow identifiers starting with a letter or underscore.

**Original Pull Request:** https://github.com/doctrine/orm/pull/717 **State:** closed **Merged:** Yes --- Using a query parameter of which the name starts with an underscore results in a QueryException. For example: ``` php $q = $em->createQueryBuilder() ->select("u") ->from("User", "u") ->where("u.username = :_name") ->setParameter("_name", "bar") ->getQuery(); ``` Results in: ``` Invalid parameter format, : given, but :<name> or ?<num> expected. ``` This happens because of a bug in the Lexer, which recognizes `:_name` as two tokens (the `:` as the start of a input parameter, `_name` as an identifier). The attached patch changes the regular expression for input parameters to allow identifiers starting with a letter or underscore.
admin added the pull-request label 2026-01-22 16:00:43 +01:00
admin closed this issue 2026-01-22 16:00:44 +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#8605