Ticket #1149 (closed defect: fixed)
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
Change History
Note: See
TracTickets for help on using
tickets.