"doctrine:mapping:import" does not escape quotes in field comments #6264

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

Originally created by @guillaume-a on GitHub (Jun 27, 2019).

Originally assigned to: @lcobucci on GitHub.

Bug Report

Hi, I made this repo to reproduce easily this bug : https://github.com/guillaume-a/doctrine-orm-7763

I don't really know how to create a PR, and I don't event know if my solution is the best way.

Q A
BC Break no
Version 2.6.3

Summary

After creating the following table in my DB

CREATE TABLE `unicorn` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(40) NOT NULL COMMENT 'enter a "comment" here'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I try to import the mapping and generate getters/setters.
The following exception appears

In AnnotationException.php line 42:
                                                                                 
  [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_CURLY_B  
  RACES, got 'comment' at position 122 in property App\Entity\Unicorn::$name

Because the annotation generated for the 'name' field is as :

// src/Entity/Unicorn.php
/**
 * @var string
 *
 * @ORM\Column(name="name", type="string", length=40, nullable=false, options={"comment"="enter a "comment" here"})
 */
private $name;

How to reproduce

Follow README.md from https://github.com/guillaume-a/doctrine-orm-7763

Expected behavior

We expected quotes to be escaped or doubled like so :

// src/Entity/Unicorn.php
/**
 * @var string
 *
 * @ORM\Column(name="name", type="string", length=40, nullable=false, options={"comment"="enter a ""comment"" here"})
 */
private $name;
Originally created by @guillaume-a on GitHub (Jun 27, 2019). Originally assigned to: @lcobucci on GitHub. ### Bug Report Hi, I made this repo to reproduce easily this bug : https://github.com/guillaume-a/doctrine-orm-7763 I don't really know how to create a PR, and I don't event know if my solution is the best way. | Q | A |------------ | ------ | BC Break | no | Version | 2.6.3 #### Summary After creating the following table in my DB ``` CREATE TABLE `unicorn` ( `id` int(10) UNSIGNED NOT NULL, `name` varchar(40) NOT NULL COMMENT 'enter a "comment" here' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ``` I try to import the mapping and generate getters/setters. The following exception appears ``` In AnnotationException.php line 42: [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_CURLY_B RACES, got 'comment' at position 122 in property App\Entity\Unicorn::$name ``` Because the annotation generated for the 'name' field is as : ``` // src/Entity/Unicorn.php /** * @var string * * @ORM\Column(name="name", type="string", length=40, nullable=false, options={"comment"="enter a "comment" here"}) */ private $name; ``` #### How to reproduce Follow README.md from https://github.com/guillaume-a/doctrine-orm-7763 #### Expected behavior We expected quotes to be escaped or doubled like so : ``` // src/Entity/Unicorn.php /** * @var string * * @ORM\Column(name="name", type="string", length=40, nullable=false, options={"comment"="enter a ""comment"" here"}) */ private $name; ```
admin added the Bug label 2026-01-22 15:29:51 +01:00
admin closed this issue 2026-01-22 15:29:52 +01:00
Author
Owner

@guillaume-a commented on GitHub (Jun 27, 2019):

made this PR : https://github.com/doctrine/orm/pull/7764

@guillaume-a commented on GitHub (Jun 27, 2019): made this PR : https://github.com/doctrine/orm/pull/7764
Author
Owner

@lcobucci commented on GitHub (Oct 2, 2019):

Handled by #7764. Thanks @guillaume-a 👍

@lcobucci commented on GitHub (Oct 2, 2019): Handled by #7764. Thanks @guillaume-a :+1:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6264