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_]*' ); } 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'";