Doctrine 1
  1. Doctrine 1
  2. DC-1020

In the Timestampable Listener, the 'alias' behavior option is not used when determining the database fieldname

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2, 1.2.3, 1.2.4
    • Fix Version/s: None
    • Component/s: Timestampable
    • Labels:
      None
    • Environment:
      PHP 5.3.5, MySQL 5.5.9; as well as PHP 5.3.6, MySQL 5.0.92

      Description

      I noticed this issue after setting up timestampable behavior on an aliased column in a legacy table:

       
      <?php
      
      abstract class Content_Article extends Doctrine_Record
      {
      
        public function setTableDefinition()
        {
          $this->setTableName('t_content');
          
          $this->hasColumn('id', 'integer', 11, array('primary' => true, 'autoincrement' => true));
          // ...
          $this->hasColumn('datePost as posted_at', 'timestamp');
          $this->hasColumn('dateEdit as updated_at', 'timestamp');
          // ...
          
        }
        
        public function setUp()
        { 
          // ..
          $this->actAs('Timestampable', array('created' => array( 'name' => 'datePost',
                                                                  'alias' => 'posted_at'),
                                              'updated' => array( 'name' => 'dateEdit',
                                                                  'alias' => 'updated_at')));
        }
      
      }
      

      Before I added timestampable to this model, I was setting the timestamp fields manually, which worked fine.

      I had to look at the source to find the alias option in the timestampable behavior, since it does not appear to be in the 1.2 documentation. (If this issue is invalid because it's not an officially supported option, I apologize).

      After I added timestampable to the model, Doctrine began throwing an exception when I tried to save a new record:

      Error: Doctrine_Record_UnknownPropertyException [ 0 ]: Unknown record property / related component "datePost" on "Content_Article" ~ [...]/Doctrine-1.2.4/Doctrine/Record/Filter/Standard.php

      It appears that the alias option is used when setting the table definition in the behavior template, but not used by the template's listener when creating, updating, etc.

      I'm attaching a zip with a copy of the changes I made to fix this in 1.2.4 and a git patch.

        Activity

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Will Mitchell
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: