Doctrine 1
  1. Doctrine 1
  2. DC-329

Problem saving Self Referencing (Nest Relations)

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: Relations
    • Labels:
      None
    • Environment:
      Mac OSX 10.5, Symfony 1.4 and MAMP

      Description

      There is a problem when you save Many to Many Self Referencing (Nest Relations).

      I used the same example that it's used on Doctrine 1.2 Self Referencing (Nest Relations) Documentation:

      My Schema:

      User:
      columns:
      name:

      Unknown macro: { type}

      relations:
      Parents:
      class: User
      local: child_id
      foreign: parent_id
      refClass: UserReference
      foreignAlias: Children

      UserReference:
      columns:
      parent_id:
      type: integer
      primary: true
      child_id:
      type: integer
      primary: true

      Fixtures:

      User:
      james:
      name: James
      alexander:
      name: Alexander
      david:
      name: David

      The problem happens with the Children. The first time I assigned children and saved the User, there is no problem; but when I saved the User again (without any change on him) the values in the UserReference? table changes: the "parent_id" takes the value of the "child_id".

      I test it with Sf 1.4 and with Sf 1.3 stable versions, and I've got the same error.

      If it not clear to understand what I'm saying, I put a "very ilustrative" image about the form and how change the values of the UserReference? table. Please see it, because it would be very usefull for understanding (explains better than my terrible English)

      Thanks for all your work!

      P. D.

      I forgot to to say that watching the stack trace I think that the problem is in:

      symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php

      In the line 429:

      public function saveAssociations(Doctrine_Record $record)

      I would like to help more, but I couldn't figure out how this function works.

      1. schema.yml
        0.4 kB
        Filippo De Santis
      2. testEqualNestRelationsTest.php
        4 kB
        Filippo De Santis
      3. testNestedEqualRelationWithObjectsTest.php
        3 kB
        Filippo De Santis
      1. saving process.png
        63 kB

        Activity

        Jaime Suez created issue -
        Jaime Suez made changes -
        Field Original Value New Value
        Attachment saving process.png [ 10216 ]
        Jonathan H. Wage made changes -
        Description
        There is a problem when you save Many to Many Self Referencing (Nest Relations).

        I used the same example that it's used on Doctrine 1.2 Self Referencing (Nest Relations) Documentation:

        My Schema:

        {quote}
        User:
          columns:
            name: { type: string(255), notnull: true }
          relations:
            Parents:
              class: User
              local: child_id
              foreign: parent_id
              refClass: UserReference
              foreignAlias: Children

        UserReference:
          columns:
            parent_id:
              type: integer
              primary: true
            child_id:
              type: integer
              primary: true
        {quote}

        Fixtures:

        {quote}
        User:
          james:
            name: James
          alexander:
            name: Alexander
          david:
            name: David
        {quote}

        The problem happens with the Children. The first time I assigned children and saved the User, there is no problem; but when I saved the User again (without any change on him) the values in the UserReference? table changes: the "parent_id" takes the value of the "child_id".

        I test it with Sf 1.4 and with Sf 1.3 stable versions, and I've got the same error.

        If it not clear to understand what I'm saying, I put a "very ilustrative" image about the form and how change the values of the UserReference? table. Please see it, because it would be very usefull for understanding (explains better than my terrible English)

        Thanks for all your work!

        P. D.

        I forgot to to say that watching the stack trace I think that the problem is in:

        symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php

        In the line 429:

        {quote}
        public function saveAssociations(Doctrine_Record $record)
        {quote}

        I would like to help more, but I couldn't figure out how this function works.
        There is a problem when you save Many to Many Self Referencing (Nest Relations).

        I used the same example that it's used on Doctrine 1.2 Self Referencing (Nest Relations) Documentation:

        My Schema:

        {quote}
        User:
          columns:
            name: { type: string(255), notnull: true }
          relations:
            Parents:
              class: User
              local: child_id
              foreign: parent_id
              refClass: UserReference
              foreignAlias: Children

        UserReference:
          columns:
            parent_id:
              type: integer
              primary: true
            child_id:
              type: integer
              primary: true
        {quote}

        Fixtures:

        {quote}
        User:
          james:
            name: James
          alexander:
            name: Alexander
          david:
            name: David
        {quote}

        The problem happens with the Children. The first time I assigned children and saved the User, there is no problem; but when I saved the User again (without any change on him) the values in the UserReference? table changes: the "parent_id" takes the value of the "child_id".

        I test it with Sf 1.4 and with Sf 1.3 stable versions, and I've got the same error.

        If it not clear to understand what I'm saying, I put a "very ilustrative" image about the form and how change the values of the UserReference? table. Please see it, because it would be very usefull for understanding (explains better than my terrible English)

        Thanks for all your work!

        P. D.

        I forgot to to say that watching the stack trace I think that the problem is in:

        symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php

        In the line 429:

        {quote}
        public function saveAssociations(Doctrine_Record $record)
        {quote}

        I would like to help more, but I couldn't figure out how this function works.
        Fix Version/s 1.2.2 [ 10047 ]
        Fix Version/s 1.2.1 [ 10044 ]
        Roman S. Borschel made changes -
        Assignee Roman S. Borschel [ romanb ] Jonathan H. Wage [ jwage ]
        Filippo De Santis made changes -
        Attachment schema.yml [ 10260 ]
        Attachment testEqualNestRelationsTest.php [ 10261 ]
        Attachment testNestedEqualRelationWithObjectsTest.php [ 10262 ]
        Jonathan H. Wage made changes -
        Fix Version/s 1.2.3 [ 10051 ]
        Fix Version/s 1.2.2 [ 10047 ]
        Pierrot Evrard made changes -
        Attachment h2aEqualable.zip [ 10505 ]
        Jonathan H. Wage made changes -
        Fix Version/s 1.2.3 [ 10051 ]

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Jaime Suez
          • Votes:
            14 Vote for this issue
            Watchers:
            14 Start watching this issue

            Dates

            • Created:
              Updated: