Ticket #1149 (closed defect: fixed)

Opened 13 months ago

Last modified 10 months ago

Inheritance map produces incorrect isnert statement

Reported by: tamcy Owned by: romanb
Priority: major Milestone:
Component: Record Version: 0.11.0
Severity: Keywords:
Cc: Has Test: no
Status: Pending Core Response Has Patch: yes

Description

Consider the following code:

<?php

class Entity extends Doctrine_Record
{
    public function setTableDefinition()
    {
        // ....
        // this column is used for column
        // aggregation inheritance
        $this->hasColumn('entity_type as type', 'integer', 11);
        $this->setSubclasses(array(
            'User'  => array('entity_type' => 1),
            'Group' => array('entity_type' => 2)
        ));
    }
}

class User extends Entity {}
class Group extends Entity {}

?>

When saving a new User, Doctrine_Record::getPrepared() would form an array like this:

 [type] => NULL
 [entity_type] => 1

And such array will be translated to SQL like: INSERT INTO entity (entity_type, entity_type) VALUES (NULL, 1) which would result in access violation in MySQL.

Using alias in setSubclasses() doesn't work either. It would cause the aliased column used during select query, and breaks consistency because we use real column name when defining indices and relations.

Attachments

Record.php.diff (433 bytes) - added by tamcy 13 months ago.
The last patch was wrong. Here's the correct one

Change History

Changed 13 months ago by tamcy

The last patch was wrong. Here's the correct one

Changed 12 months ago by jwage

  • milestone changed from 0.11.3 to 0.11.1

Changed 12 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [4596]) fixes #1149

Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.