Doctrine 1
  1. Doctrine 1
  2. DC-1009

save() also updates fields which should not be

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Query
    • Labels:
      None
    • Environment:
      Windows server 2003 PHP 5.2.17 / XP PRO 32bits XAMPP PHP 5.3.5
      MSSQL / MYSQL
      Symfony 1.4.6

      Description

      When I want to do a simple update like this :

      $batches = ExamResultsBatchTable::getInstance()->retrieveByExamBatchStatus(ExamResultsBatch::valid_status_code);
      foreach($batches as $batch)
      {
      $batch->setExamBatchStatusId($batchStatusId);
      $batch->setStatusDate(date('Y-m-d'));
      $batch->save();
      }
      Only exam_batch_status_id and status_date should be updated (see screenshot before), but columns exam_batch_status_id ,status_date AND exam_subject_id are updated,with the same value (23) (screenshot after_with_save).

      If I run this:
      $toto = Doctrine_Query::create()
      ->update('ExamResultsBatch erb')
      ->set('erb.exam_batch_status_id', 23)
      ->set('erb.status_date', date('Y-m-d'))
      >where('erb.id = ?' , $batch>getId())
      ->execute();
      Everything is correctly done.

      here is the simpliest case.

      The same problems are signaled on other tables in the database, but different tables can be impacted by one save() (the execute() query still works fine).

      Example : 2 foreign tables will be updated , even if the save() action should only concern the main table, and one field (which is not a foreign key).
      The corresponding foreign key fields in the 2 foreign tables, will be updated with the value given (here 23).

      Because save() is used in a lot of different places in our app, I need to find a solution to fix save(), or if not possible to override it to run a execute()like query.

      Thanks for your help.
      Don't hesitate to ask if you want more details.

      Yan

      1. retrieveByExamBatchStatus.php
        1 kB
        Yan Urquiza
      2. schema.yml
        4 kB
        Yan Urquiza
      1. after_with_execute.PNG
        108 kB
      2. after_with_save.PNG
        108 kB
      3. before.PNG
        106 kB

        Activity

        Yan Urquiza created issue -
        Yan Urquiza made changes -
        Field Original Value New Value
        Summary save() also updates fields should not be save() also updates fields which should not be
        Description When I want to do a simple update like this :
                $batches = ExamResultsBatchTable::getInstance()
                                ->retrieveByExamBatchStatus(ExamResultsBatch::valid_status_code);

        foreach($batches as $batch)
        {
                $batch->setExamBatchStatusId($batchStatusId);
                $batch->setStatusDate(date('Y-m-d'));
                $batch->save();
        }
        Only exam_batch_status_id and status_date should be updated (see screenshot before), but columns exam_batch_status_id ,status_date AND exam_subject_id are updated,with the same value (23) (screenshot after_with_save).

        If I run this:
                $toto = Doctrine_Query::create()
                               ->update('ExamResultsBatch erb')
                                ->set('erb.exam_batch_status_id', 23)
                                ->set('erb.status_date', date('Y-m-d'))
                               ->where('erb.id = ?' , $batch->getId())
                               ->execute();
        Everything is correctly done.

        here is the simpliest case.
        The same problems are signaled on other tables in the database, but different tables can be impacted by one save() (the execute() query still works fine).
        Example : 2 foreign tables will be updated , even if the save() action should only concern the main table, and one field (which is not a foreign key).
        The corresponding foreign key fields in the 2 foreign tables, will be updated with the value given (here 23).
        Because save() is used in a lot of different places in our app, I need to find a solution to fix save(), or if not possible to override it to run a execute()like query.

        Thanks for your help.
        Don't hesitate to ask if you want more details.

        Yan
        When I want to do a simple update like this :

         $batches = ExamResultsBatchTable::getInstance()->retrieveByExamBatchStatus(ExamResultsBatch::valid_status_code);
        foreach($batches as $batch)
        {
                $batch->setExamBatchStatusId($batchStatusId);
                $batch->setStatusDate(date('Y-m-d'));
                $batch->save();
        }
        Only exam_batch_status_id and status_date should be updated (see screenshot before), but columns exam_batch_status_id ,status_date AND exam_subject_id are updated,with the same value (23) (screenshot after_with_save).

        If I run this:
                $toto = Doctrine_Query::create()
                               ->update('ExamResultsBatch erb')
                                ->set('erb.exam_batch_status_id', 23)
                                ->set('erb.status_date', date('Y-m-d'))
                               ->where('erb.id = ?' , $batch->getId())
                               ->execute();
        Everything is correctly done.

        here is the simpliest case.

        The same problems are signaled on other tables in the database, but different tables can be impacted by one save() (the execute() query still works fine).

        Example : 2 foreign tables will be updated , even if the save() action should only concern the main table, and one field (which is not a foreign key).
        The corresponding foreign key fields in the 2 foreign tables, will be updated with the value given (here 23).

        Because save() is used in a lot of different places in our app, I need to find a solution to fix save(), or if not possible to override it to run a execute()like query.

        Thanks for your help.
        Don't hesitate to ask if you want more details.

        Yan
        Attachment schema.yml [ 11013 ]
        Attachment retrieveByExamBatchStatus.php [ 11014 ]
        Yan Urquiza made changes -
        Environment Windows server 2003 / XP PRO 32bits
        MSSQL / MYSQL
        Symfony 1.4.6
        Windows server 2003 PHP 5.2.17 / XP PRO 32bits XAMPP PHP 5.3.5
        MSSQL / MYSQL
        Symfony 1.4.6

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

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Yan Urquiza
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: