Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2035

XML Mapping : add attribute "length" for tag "id"

    Details

    • Type: New Feature New Feature
    • Status: Awaiting Feedback
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.3
    • Fix Version/s: None
    • Component/s: Mapping Drivers
    • Security Level: All
    • Labels:
      None
    • Environment:
      Linux, Doctrine ORM 2.3.0, MySQL

      Description

      XML mapping :

      <id name="id" type="string" length="16"/>

      Generate SQL :

      id varchar(255) not null

      It's not possible with XML mapping to have :

       id varchar(16) not null

      Because tag "id" doesn't support "length" attribute.
      Please add this attribute

        Activity

        Erik Müller created issue -
        Erik Müller made changes -
        Field Original Value New Value
        Affects Version/s 2.3 [ 10185 ]
        Affects Version/s 2.0.3 [ 10117 ]
        Environment Linux, Doctrine ORM 2.0.3 on Symfony2, MySQL. Linux, Doctrine ORM 2.3.0, MySQL
        Description *XML mapping :*
        {code}<id name="id" type="integer">
              <generator strategy="IDENTITY"/>
        </id>{code}

        *Generate SQL :*
        {code}id int auto_increment not null{code}

        *It's not possible with XML mapping to have :*
        {code} id int UNSIGNED not null auto_increment{code}

        Because tag "id" doesn't support "column-definition" attribute.
        We can have same problem for others types parameters.

        *I suggest this solution : in file <Doctrine/ORM/Mapping/Driver/XmlDriver.php>*
        {code}
        // add this code to line 226 ( in the "Evaluate <id ...>" bloc after the array "mapping" ) :

        if(isset($idElement['column-definition'])){
                        $mapping['columnDefinition'] = (string)$idElement['column-definition'];
        }
        {code}

        *New XML mapping :*
        {code}<id name="id" type="integer" column="id" column-definition="INT unsigned NOT NULL" >
              <generator strategy="IDENTITY"/>
        </id>{code}

        *Warning : "column-definition" must not contains "AUTO_INCREMENT" (added automaticly) :*
        {code}<id name="id" type="integer" column="id" column-definition="INT unsigned NOT NULL AUTO_INCREMENT" >
              <generator strategy="IDENTITY"/>
        </id>{code}

        With "AUTO_INCREMENT" in column-definition all foreign keys contain this parameter.
        *XML mapping :*
        {code}<id name="id" type="string" length="16"/>{code}

        *Generate SQL :*
        {code}id varchar(255) not null{code}

        *It's not possible with XML mapping to have :*
        {code} id varchar(16) not null{code}

        Because tag "id" doesn't support "length" attribute.
        We can have same problem for others types parameters.

        Please add this attribute
        Fix Version/s 2.2 [ 10157 ]
        Erik Müller made changes -
        Description *XML mapping :*
        {code}<id name="id" type="string" length="16"/>{code}

        *Generate SQL :*
        {code}id varchar(255) not null{code}

        *It's not possible with XML mapping to have :*
        {code} id varchar(16) not null{code}

        Because tag "id" doesn't support "length" attribute.
        We can have same problem for others types parameters.

        Please add this attribute
        *XML mapping :*
        {code}<id name="id" type="string" length="16"/>{code}

        *Generate SQL :*
        {code}id varchar(255) not null{code}

        *It's not possible with XML mapping to have :*
        {code} id varchar(16) not null{code}

        Because tag "id" doesn't support "length" attribute.
        Please add this attribute
        Erik Müller made changes -
        Affects Version/s 2.2.3 [ 10196 ]
        Affects Version/s 2.3 [ 10185 ]
        Hide
        Fabio B. Silva added a comment -

        Hi Erik,

        The atribute "id" arealdy support "length" in the current doctrine version
        : https://github.com/doctrine/doctrine2/blob/2.3/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php#L259

        Which version are you using ?

        Show
        Fabio B. Silva added a comment - Hi Erik, The atribute "id" arealdy support "length" in the current doctrine version : https://github.com/doctrine/doctrine2/blob/2.3/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php#L259 Which version are you using ?
        Fabio B. Silva made changes -
        Status Open [ 1 ] Awaiting Feedback [ 10000 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2035, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Fabio B. Silva
            Reporter:
            Erik Müller
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: