Doctrine 1
  1. Doctrine 1
  2. DC-979

Doctrine save() only checks one level deep on one-to-one relations.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.1, 1.2.2, 1.2.3
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None
    • Environment:
      MySQL 5.1.38, PHP 5.3.3

      Description

      Updating/saving an object fails when trying to update the nth-level of an existing object/relation where n is more than one level away from the root node of one-to-one relation chain. For example, with the yaml model below the following does not update the name of the Company object:

      Image->Product->Category->Company->name = "Acme".

      If "Product" has no changes it appears to stop checking for changes there. If we do a save on a one-to-many relation chain such as the following, it works fine:

      Company->Category->Product->Image->name = "image1.jpg"

      I was able to fix this issue by modifying the saveRelatedLocalKeys() function in UnitOfWork.php to use isModified() with deep=true:

      if ($obj instanceof Doctrine_Record && $obj->isModified(true)) {

      This works but I'm not sure if changing this has any repercussions on more complex queries.


      detect_relations: true
      options:
      collate: utf8_general_ci
      charset: utf8
      type: InnoDB

      Company:
      tableName: Company
      columns:
      id:
      type: integer(4)
      primary: true
      notnull: true
      autoincrement: true
      name:
      type: string(45)

      Category:
      tableName: Category
      columns:
      id:
      type: integer(4)
      primary: true
      notnull: true
      autoincrement: true
      companyId:
      type: integer(4)
      notnull: true
      name:
      type: string(45)
      relations:
      Company:
      class: Company
      local: companyId
      foreign: id
      foreignAlias: categories
      onDelete: cascade
      onUpdate: cascade
      indexes:
      fk_Category_Company1:
      fields: [companyId]

      Product:
      tableName: Product
      columns:
      id:
      type: integer(4)
      primary: true
      notnull: true
      autoincrement: true
      categoryId:
      type: integer(4)
      notnull: true
      name:
      type: string(45)
      relations:
      Category:
      class: Category
      local: categoryId
      foreign: id
      foreignAlias: products
      onDelete: cascade
      onUpdate: cascade
      indexes:
      fk_Product_Category1:
      fields: [categoryId]

      Image:
      tableName: Image
      columns:
      id:
      type: integer(4)
      primary: true
      notnull: true
      autoincrement: true
      productId:
      type: integer(4)
      notnull: true
      name:
      type: string(45)
      relations:
      Product:
      class: Product
      local: productId
      foreign: id
      foreignAlias: images
      onDelete: cascade
      onUpdate: cascade
      indexes:
      fk_Image_Product1:
      fields: [productId]

        Activity

        There are no comments yet on this issue.

          People

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

            Dates

            • Created:
              Updated: