Error when create query for entity named Order #6245

Closed
opened 2026-01-22 15:29:30 +01:00 by admin · 4 comments
Owner

Originally created by @frimuchkov on GitHub (Jun 4, 2019).

Originally assigned to: @Ocramius on GitHub.

Bug Report

Q A
BC Break yes/no
Version 2.6.3

Current behavior

Get exception:
Fatal error: Uncaught Doctrine\ORM\Query\QueryException: SELECT o FROM Order o in /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:43 Stack trace: #0 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(456): Doctrine\ORM\Query\QueryException::dqlError('SELECT o FROM O...') #1 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(314): Doctrine\ORM\Query\Parser->syntaxError('Doctrine\\ORM\\Qu...') #2 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(974): Doctrine\ORM\Query\Parser->match(100) #3 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(1732): Doctrine\ORM\Query\Parser->AbstractSchemaName() #4 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(1584): Doctrine\ORM\Query\Parser->RangeVariableDeclaration() #5 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(1319): Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration() #6 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(878 in /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php on line 54

How to reproduce

Crete entity with class name Order and execute:
$entityManager->getRepository('Order')->createQueryBuilder('o')->select('o')->getQuery()->getSQL();

Expected behavior

Correct sql

Originally created by @frimuchkov on GitHub (Jun 4, 2019). Originally assigned to: @Ocramius on GitHub. ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes/no | Version | 2.6.3 #### Current behavior Get exception: ` Fatal error: Uncaught Doctrine\ORM\Query\QueryException: SELECT o FROM Order o in /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:43 Stack trace: #0 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(456): Doctrine\ORM\Query\QueryException::dqlError('SELECT o FROM O...') #1 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(314): Doctrine\ORM\Query\Parser->syntaxError('Doctrine\\ORM\\Qu...') #2 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(974): Doctrine\ORM\Query\Parser->match(100) #3 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(1732): Doctrine\ORM\Query\Parser->AbstractSchemaName() #4 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(1584): Doctrine\ORM\Query\Parser->RangeVariableDeclaration() #5 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(1319): Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration() #6 /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(878 in /var/www/ops/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php on line 54` #### How to reproduce Crete entity with class name Order and execute: ` $entityManager->getRepository('Order')->createQueryBuilder('o')->select('o')->getQuery()->getSQL();` #### Expected behavior Correct sql
admin added the Invalid label 2026-01-22 15:29:30 +01:00
admin closed this issue 2026-01-22 15:29:30 +01:00
Author
Owner
@Ocramius commented on GitHub (Jun 4, 2019): Closing here: see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/limitations-and-known-issues.html#identifier-quoting-and-legacy-databases
Author
Owner

@frimuchkov commented on GitHub (Jun 4, 2019):

Closing here: see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/limitations-and-known-issues.html#identifier-quoting-and-legacy-databases

No, it's a different problem
There is @Table(name="orders", indexes={@Index(columns={"title", "note"}, flags={"fulltext"})})

@frimuchkov commented on GitHub (Jun 4, 2019): > Closing here: see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/limitations-and-known-issues.html#identifier-quoting-and-legacy-databases No, it's a different problem There is `@Table(name="orders", indexes={@Index(columns={"title", "note"}, flags={"fulltext"})})`
Author
Owner

@frimuchkov commented on GitHub (Jun 4, 2019):

@Ocramius
There is strings in Lexer.php:
$name = 'Doctrine\ORM\Query\Lexer::T_' . strtoupper($value);

So, for this valid DQL: SELECT o FROM Order o method return incorrect type of Order

@frimuchkov commented on GitHub (Jun 4, 2019): @Ocramius There is strings in `Lexer.php`: ` $name = 'Doctrine\ORM\Query\Lexer::T_' . strtoupper($value); ` So, for this valid DQL: `SELECT o FROM Order o` method return incorrect type of `Order`
Author
Owner

@Ocramius commented on GitHub (Jun 4, 2019):

Ah yep, you will indeed need to namespace your entity

On Tue, Jun 4, 2019, 22:26 Andrey Frimuchkov notifications@github.com
wrote:

@Ocramius https://github.com/Ocramius
There is strings in Lexer.php:
` $name = 'Doctrine\ORM\Query\Lexer::T_' . strtoupper($value);
if (defined($name)) {
$type = constant($name);

            if ($type > 100) {
                print_r($name.'<br>');
                return $type;
            }
        }`

So, for this valid DQL: SELECT o FROM Order o method return incorrect
type of Order


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/orm/issues/7734?email_source=notifications&email_token=AABFVEEF4V45SRQCGWLPV6TPY3FXLA5CNFSM4HTAJWI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW5YVGI#issuecomment-498829977,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABFVEEDSZ22JYLF6RNEX5LPY3FXLANCNFSM4HTAJWIQ
.

@Ocramius commented on GitHub (Jun 4, 2019): Ah yep, you will indeed need to namespace your entity On Tue, Jun 4, 2019, 22:26 Andrey Frimuchkov <notifications@github.com> wrote: > @Ocramius <https://github.com/Ocramius> > There is strings in Lexer.php: > ` $name = 'Doctrine\ORM\Query\Lexer::T_' . strtoupper($value); > if (defined($name)) { > $type = constant($name); > > if ($type > 100) { > print_r($name.'<br>'); > return $type; > } > }` > > So, for this valid DQL: SELECT o FROM Order o method return incorrect > type of Order > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/orm/issues/7734?email_source=notifications&email_token=AABFVEEF4V45SRQCGWLPV6TPY3FXLA5CNFSM4HTAJWI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW5YVGI#issuecomment-498829977>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AABFVEEDSZ22JYLF6RNEX5LPY3FXLANCNFSM4HTAJWIQ> > . >
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6245