Skip to content

Commit 8104c65

Browse files
authored
Merge pull request #7987 from beberlei/GH-7982-NoSqlExecutor
[GH-7982] no sql executor leads to parse error
2 parents fdad482 + a64d254 commit 8104c65

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

lib/Doctrine/ORM/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ final class Query extends AbstractQuery
133133
*
134134
* @var integer
135135
*/
136-
private $_state = self::STATE_CLEAN;
136+
private $_state = self::STATE_DIRTY;
137137

138138
/**
139139
* A snapshot of the parameter types the query was parsed with.

lib/Doctrine/ORM/Query/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function __construct(Query $query)
189189
{
190190
$this->query = $query;
191191
$this->em = $query->getEntityManager();
192-
$this->lexer = new Lexer($query->getDQL());
192+
$this->lexer = new Lexer((string) $query->getDQL());
193193
$this->parserResult = new ParserResult();
194194
}
195195

tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public function invalidDQL()
134134
['SELECT \'foo\' AS foo\\\\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
135135
['SELECT \'foo\' AS foo: FROM Doctrine\Tests\Models\CMS\CmsUser u'],
136136
['SELECT \'foo\' AS foo:bar FROM Doctrine\Tests\Models\CMS\CmsUser u'],
137+
138+
['0'],
137139
];
138140
}
139141

tests/Doctrine/Tests/ORM/Query/QueryTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,13 @@ public function testValuesAreNotBeingResolvedForSpecifiedParameterTypes() : void
420420

421421
self::assertEmpty($query->getResult());
422422
}
423+
424+
/** @group 7982 */
425+
public function testNonExistentExecutor()
426+
{
427+
$this->expectException(QueryException::class);
428+
$this->expectExceptionMessage('[Syntax Error] line 0, col -1: Error: Expected SELECT, UPDATE or DELETE, got end of string.');
429+
430+
$query = $this->_em->createQuery('0')->execute();
431+
}
423432
}

0 commit comments

Comments
 (0)