[PR #1261] [WIP] Add a new QuoteStrategy that automatically escape database reserved keyword #9318

Open
opened 2026-01-22 16:03:56 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/1261

State: closed
Merged: No


All the upload screenshots which are used to explain what we are doing are taken from a real project developed with Mouf dependency injection framework (http://mouf-php.com/) that we use to configure the entity manager.

We wanted to create a FAQ where admin can add question/answer and use drag and drop to set the position of the question in the FAQ.

For this, at some point, in an entity, we used a protected keyword "order" in a class FAQ:

    /**
     * @ORM\Column(type="integer", nullable=false)
     * @var int
     */
    private $order;

This fails with Doctrine. The documentation clearly explains why: http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#quoting-reserved-words

Below are a list of screenshot explaining we use the DefaultQuoteStrategy and the failure message we get.

doctrineconfiguration

In the configuration,the "quoteStrategy" setter is not set. Therefore, we use DefaultQuoteStrategy.

defaultquotestrategy

We get this error:

error
We get an error while using doctrine ORM because it doesn't auto escape protected keyword. (We can protect it manually by using ` .)

We created a new QuoteStratigy that automaticcaly escape protected keyword only. We just bind it via the Mouf interface:

escapingquotestrategy

and then the magic begins: a screenshot of the page with no error.

succes

We would like to submit this new EscapingQuoteStrategy as we think it will be easier for developers to work with it, and it should not have a big performance impact (only an additional lookup in a table)

**Original Pull Request:** https://github.com/doctrine/orm/pull/1261 **State:** closed **Merged:** No --- All the upload screenshots which are used to explain what we are doing are taken from a real project developed with Mouf dependency injection framework (http://mouf-php.com/) that we use to configure the entity manager. We wanted to create a FAQ where admin can add question/answer and use drag and drop to set the position of the question in the FAQ. For this, at some point, in an entity, we used a protected keyword "order" in a class FAQ: ``` /** * @ORM\Column(type="integer", nullable=false) * @var int */ private $order; ``` This fails with Doctrine. The documentation clearly explains why: http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#quoting-reserved-words Below are a list of screenshot explaining we use the `DefaultQuoteStrategy` and the failure message we get. ![doctrineconfiguration](https://cloud.githubusercontent.com/assets/8350192/5779969/4ab5c15e-9da7-11e4-8df8-f2c718c8d66a.PNG) In the configuration,the "quoteStrategy" setter is not set. Therefore, we use `DefaultQuoteStrategy`. ![defaultquotestrategy](https://cloud.githubusercontent.com/assets/8350192/5779977/51fe0a70-9da7-11e4-9cfa-3a86e6f8aab8.PNG) We get this error: ![error](https://cloud.githubusercontent.com/assets/8350192/5779963/422e0bc2-9da7-11e4-902c-602a2eac7f96.PNG) We get an error while using doctrine ORM because it doesn't auto escape protected keyword. (We can protect it manually by using ` .) We created a new QuoteStratigy that automaticcaly escape protected keyword **only**. We just bind it via the Mouf interface: ![escapingquotestrategy](https://cloud.githubusercontent.com/assets/8350192/5780067/d9997bae-9da7-11e4-8a23-c5fa2ebaffcc.PNG) and then the magic begins: a screenshot of the page with no error. ![succes](https://cloud.githubusercontent.com/assets/8350192/5780085/f9b597f6-9da7-11e4-85b0-cd09fb572cd9.PNG) We would like to submit this new `EscapingQuoteStrategy` as we think it will be easier for developers to work with it, and it should not have a big performance impact (only an additional lookup in a table)
admin added the pull-request label 2026-01-22 16:03:56 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9318