From 6aa58d9939018f1960106f03b5d440e916e01867 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 4 Jul 2013 10:12:36 +0200 Subject: [PATCH 1/2] Allow query parameters starting with an underscore --- lib/Doctrine/ORM/Query/Lexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index bf0b5f6db..d5721a735 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -129,7 +129,7 @@ class Lexer extends \Doctrine\Common\Lexer '[a-z_\\\][a-z0-9_\:\\\]*[a-z0-9_]{1}', '(?:[0-9]+(?:[\.][0-9]+)*)(?:e[+-]?[0-9]+)?', "'(?:[^']|'')*'", - '\?[0-9]*|:[a-z]{1}[a-z0-9_]{0,}' + '\?[0-9]*|:[a-z_][a-z0-9_]*' ); } From b5394fc5a0303401a69fdfc5ae020f3ff1a2a792 Mon Sep 17 00:00:00 2001 From: Paul Hooijenga Date: Fri, 5 Jul 2013 09:21:24 +0200 Subject: [PATCH 2/2] Add test for query paremeters starting with underscore --- tests/Doctrine/Tests/ORM/Query/LexerTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index 29bba4bae..1798cc1ed 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -158,6 +158,15 @@ class LexerTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals(':name', $token['value']); } + public function testScannerRecognizesNamedInputParameterStartingWithUnderscore() + { + $lexer = new Lexer(':_name'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + $this->assertEquals(':_name', $token['value']); + } + public function testScannerTokenizesASimpleQueryCorrectly() { $dql = "SELECT u FROM My\Namespace\User u WHERE u.name = 'Jack O''Neil'";