No table name escape in ServiceEntityRepository->createQueryBuilder() #6214

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

Originally created by @Oihso on GitHub (Mar 31, 2019).

Originally assigned to: @Ocramius on GitHub.

Bug Report

Summary

If you have entity, that named like SQL keyword (Order in my case), you can not use $this->createQueryBuilder('...')->...; because after building the query you get SELECT ... FROM order ... query which always has non-escaped table name. As a result, you cant access table with that name.

How to reproduce

  1. Make entity named like SQL keyword
  2. Build query with $this->createQueryBuilder('...')->...;
  3. Try to execute it

P.S. Not sure, if this 'bug' relates to this repository, and not to doctrine/orm

Originally created by @Oihso on GitHub (Mar 31, 2019). Originally assigned to: @Ocramius on GitHub. ### Bug Report #### Summary If you have entity, that named like SQL keyword (`Order` in my case), you can not use `$this->createQueryBuilder('...')->...;` because after building the query you get `SELECT ... FROM order ...` query which always has non-escaped table name. As a result, you cant access table with that name. #### How to reproduce 1. Make entity named like SQL keyword 2. Build query with `$this->createQueryBuilder('...')->...;` 3. Try to execute it P.S. Not sure, if this 'bug' relates to this repository, and not to [doctrine/orm](https://github.com/doctrine/orm)
admin added the Can't FixQuestion labels 2026-01-22 15:29:00 +01:00
admin closed this issue 2026-01-22 15:29:00 +01:00
Author
Owner

@ostrolucky commented on GitHub (Apr 1, 2019):

Please try with master, one of the major changes is precisely escaping stuff like that. Will not be fixed in 2.x due to bc concerns

Edit: and yes, this relates to orm. Try master version of orm

@ostrolucky commented on GitHub (Apr 1, 2019): Please try with master, one of the major changes is precisely escaping stuff like that. Will not be fixed in 2.x due to bc concerns Edit: and yes, this relates to orm. Try master version of orm
Author
Owner
@Ocramius commented on GitHub (Apr 1, 2019): Closing here: this is documented at https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/limitations-and-known-issues.html#identifier-quoting-and-legacy-databases
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6214