Uploaded image for project: '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.


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


      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');


      'Fds_Model_Branch as branch',
      '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.
      'localTax', 'decimal', null,
      '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?


        There are no comments yet on this issue.


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


            • Created: