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

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

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/717
Author: @hackedd
Created: 7/4/2013
Status: Merged
Merged: 7/29/2013
Merged by: @guilhermeblanco

Base: masterHead: patch-1


📝 Commits (2)

  • 6aa58d9 Allow query parameters starting with an underscore
  • b5394fc Add test for query paremeters starting with underscore

📊 Changes

2 files changed (+10 additions, -1 deletions)

View changed files

📝 lib/Doctrine/ORM/Query/Lexer.php (+1 -1)
📝 tests/Doctrine/Tests/ORM/Query/LexerTest.php (+9 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/717 **Author:** [@hackedd](https://github.com/hackedd) **Created:** 7/4/2013 **Status:** ✅ Merged **Merged:** 7/29/2013 **Merged by:** [@guilhermeblanco](https://github.com/guilhermeblanco) **Base:** `master` ← **Head:** `patch-1` --- ### 📝 Commits (2) - [`6aa58d9`](https://github.com/doctrine/orm/commit/6aa58d9939018f1960106f03b5d440e916e01867) Allow query parameters starting with an underscore - [`b5394fc`](https://github.com/doctrine/orm/commit/b5394fc5a0303401a69fdfc5ae020f3ff1a2a792) Add test for query paremeters starting with underscore ### 📊 Changes **2 files changed** (+10 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/Query/Lexer.php` (+1 -1) 📝 `tests/Doctrine/Tests/ORM/Query/LexerTest.php` (+9 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 16:00:43 +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#8601