Doctrine 1
  1. Doctrine 1
  2. DC-478

Having a default value in a decimal field in base class forces Doctrine to try to save an instance even if not required.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None
    • Environment:
      Linux, PHP 5.3

      Description

      I have 2 classes. Order and Branch. An Order class can have one or no branch assigned to it. My base class definition for a branch is simple. It just has a name.

      The Order class has:
      $this->hasColumn('branchId', 'integer');

      and

      $this->hasOne(
      'Fds_Model_Branch as branch',
      array(
      'local' => 'branchId',
      'foreign' => 'id',
      )
      );

      The branch class had this:

      $this->hasColumn('name', 'string', 50, array(
      'notnull' => true,
      'notblank' => true,
      ));

      No hasMany relation back to Orders.

      Using this setup, all my tests work.

      I added this to the Branch class.
      $this->hasColumn(
      'localTax', 'decimal', null,
      array(
      'notnull' => true,
      'default' => 0,
      )
      );

      Now my tests fail with a validator error from the branch class for the name property whenever I try to save an order that has no branch associated to it. Pretty weird right? I mean, my order has no branch, and yet Doctrine tries to save one.

      But if I change the definition of localTax to this:
      $this->hasColumn('localTax', 'decimal');

      Then my tests work as expected again. Problem is, I need to assign the default value of 0 to localTax instead of null.

      Is this a bug?

        Activity

        There are no comments yet on this issue.

          People

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

            Dates

            • Created:
              Updated: