Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2184

[GH-530] Singular form of generated methods should end with 'y' when property ends with 'ies'

    Details

    • Type: Improvement Improvement
    • Status: Awaiting Feedback
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: Tools
    • Security Level: All
    • Labels:
      None

      Description

      In Doctrine 2.3 the 'add' and 'remove' methods in oneToMany associations have another problem (in earlier versions like 2.2 this worked correct). The singular form is not correctly detected if the property ends with 'ies' like 'entries' which should be transformed to 'entry'.
      I have this YAML definition:

      Archive:
        type: entity
        fields:
          id:
            id: true
            type: integer
            unsigned: false
            nullable: false
            generator:
              strategy: IDENTITY
        oneToMany:
          entries:
            targetEntity: Entry
            mappedBy: archive
      

      This generates these methods:

      public function addEntrie(\Entry $entries) { ... }
      public function removeEntrie(\Entry $entries) { ... }
      

      Because in the EntityGenerator only the plural 's' is removed. It would be nice if an ending of 'ies' could be replaced by 'y'. So that we get these methods

      public function addEntry(\Entry $entries) { ... }
      public function removeEntry(\Entry $entries) { ... }
      

      My fork already has the changes https://github.com/naitsirch/doctrine-orm2/commit/a3adfccb4927d61da7debae46ed0fff61e4212f8
      I have opened a pull request here https://github.com/doctrine/doctrine2/pull/530

        Issue Links

          Activity

          Benjamin Eberlei created issue -
          Christian Stoller made changes -
          Field Original Value New Value
          Affects Version/s 2.3 [ 10185 ]
          Component/s Tools [ 10015 ]
          Christian Stoller made changes -
          Description This issue is created automatically through a Github pull request on behalf of naitsirch:

            Url: https://github.com/doctrine/doctrine2/pull/530

          Message:

          The singular form is not correctly detected if the property ends with 'ies' like 'entries' which should be transformed to 'entry'.
          This change is related to http://www.doctrine-project.org/jira/browse/DDC-1268
          In Doctrine 2.3 the 'add' and 'remove' methods in oneToMany associations have another problem (in earlier versions like 2.2 this worked correct). The singular form is not correctly detected if the property ends with 'ies' like 'entries' which should be transformed to 'entry'.
          I have this YAML definition:

          {code}
          Archive:
            type: entity
            fields:
              id:
                id: true
                type: integer
                unsigned: false
                nullable: false
                generator:
                  strategy: IDENTITY
            oneToMany:
              entries:
                targetEntity: Entry
                mappedBy: archive
          {code}

          This generates these methods:

          {code}
          public function addEntrie(\Entry $entries) { ... }
          public function removeEntrie(\Entry $entries) { ... }
          {code}

          Because in the EntityGenerator only the plural 's' is removed. It would be nice if an ending of 'ies' could be replaced by 'y'. So that we get these methods

          {code}
          public function addEntry(\Entry $entries) { ... }
          public function removeEntry(\Entry $entries) { ... }
          {code}

          My fork already has the changes https://github.com/naitsirch/doctrine-orm2/commit/a3adfccb4927d61da7debae46ed0fff61e4212f8
          I have opened a pull request here https://github.com/doctrine/doctrine2/pull/530
          Christian Stoller made changes -
          Status Open [ 1 ] Awaiting Feedback [ 10000 ]
          Hide
          Christian Stoller added a comment - - edited

          Sorry, I accidently clicked on the button 'Request Feedback'
          Now the status has changed to 'Awaiting Feedback'

          Show
          Christian Stoller added a comment - - edited Sorry, I accidently clicked on the button 'Request Feedback' Now the status has changed to 'Awaiting Feedback'
          Marco Pivetta made changes -
          Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]
          Hide
          Benjamin Eberlei added a comment -

          Mark as improvement

          Show
          Benjamin Eberlei added a comment - Mark as improvement
          Benjamin Eberlei made changes -
          Issue Type Bug [ 1 ] Improvement [ 4 ]
          Benjamin Eberlei made changes -
          Link This issue duplicates DDC-2150 [ DDC-2150 ]
          Benjamin Eberlei made changes -
          Link This issue duplicates DDC-2160 [ DDC-2160 ]
          Hide
          Ed Page Croft added a comment -

          Is this issue going to be resolved? It's a major problem for our project - a stock market application that uses properties like 'securities' and entities of name 'Security'.

          Show
          Ed Page Croft added a comment - Is this issue going to be resolved? It's a major problem for our project - a stock market application that uses properties like 'securities' and entities of name 'Security'.
          Ed Page Croft made changes -
          Status In Progress [ 3 ] Awaiting Feedback [ 10000 ]
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-530] was closed:
          https://github.com/doctrine/dbal/pull/530

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-530] was closed: https://github.com/doctrine/dbal/pull/530

          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-2184, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Benjamin Eberlei
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: