Doctrine 1
  1. Doctrine 1
  2. DC-433

UnitOfWork saveRelatedLocalKeys() creating erroneous child/parent rows

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Incomplete
    • Affects Version/s: 1.1.6
    • Fix Version/s: None
    • Component/s: Record, Relations
    • Labels:
      None

      Description

      This issue is a lot like the bug with refreshRelated() in ticket #DC-93. Calling save() on a record will cause hasOne rows to be generated in error (with all NULL values). It looks the saveRelatedLocalKeys function checks for foreign keys, calls isModified, which returns true, and calls save on that related object. isModified is returning true for a row that doesn't exist.

      schema.yml
       
      ---
      Staff:
        columns:
          username: string(50)
          password: string(255)
          active:
            type: boolean
            default: true
        indexes:
          user_pass_active_idx:
            fields: [username, password, active]
      
      
      Tickets:
        columns:
          mask:
            unique: true
            type: string(10)
          staff_id: integer(9)
        relations:
          Staff:
            local: staff_id
            foreign: id
      
      test.php
       
      <?php
      $ticket = new Tickets();
      $ticket->staff = null;
      // This save generates the NULL record in the staff table
      $ticket->save();
      

        Activity

        Hide
        Jonathan H. Wage added a comment -

        Hi, this patch is not valid. We can't only save records that already exist. That means it stops all new records from being saved. If you want to help fix this, first we'll need a reproducible test case. Thanks, Jon

        Show
        Jonathan H. Wage added a comment - Hi, this patch is not valid. We can't only save records that already exist. That means it stops all new records from being saved. If you want to help fix this, first we'll need a reproducible test case. Thanks, Jon

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Justin Mazzi
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: