DDC-1316: Insert statement for joined subclass presister doesn't type change the id values for subtables #1651

Closed
opened 2026-01-22 13:21:10 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (Aug 3, 2011).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user vigor_bg:

Hi there,

I am using "Class Table Inheritance" and this are my entities.

****
 * @Entity
 * @Table (name="Vehicles")
 * @InheritanceType ("JOINED")
 * @DiscriminatorColumn (name="vehicleClass", type="string")
 * @DiscriminatorMap ({"own"="OwnCar", "renta"="RentedCar"})
 */
class Vehicle
{

    /****
     * @Id
     * @Column (name="vehicleID", type="integer")
     */
    protected $vehicleID;

        /****
     * @Id
         * @Column (name="dateFrom", type="datetime")
         */
    protected $dateFrom;

       .........
}
/****
 * @Table (name="OwnCars")
 * @Entity (repositoryClass="OwnCarRepo")
 */
class OwnCars*Model_Entity_OwnCar extends OwnCars_Model_Entity*Vehicle {

}

As you can see i am using composed id keys. The problem that i get is when building the insert statement the value for the second key which is type datetime is not transformed to date transformed but cast to integer and in the data base i got inserted value of 0000-00-00 00:00:00 instead of the date that i have given. After i did a bit of debugging i found the problem to be in the "Doctrine\ORM\Persisters\JoinedSubclassPersister" on line 163.

foreach ((array) $id as $idVal) {
    $stmt->bindValue($paramIndex<ins></ins>, $idVal);
}

As you can see when you are binding the values for the subtable ids you are not giving the type for the id. So for me to work i did a quick fix:

foreach ((array) $id as $columnNameIdentifier => $idVal) {

    /****
     * Fix untyped join inherited table.
     * All identifiers was typed now.
     */
    $type = \PDO::PARAM_STR;
    if (isset($this->_columnTypes[$columnNameIdentifier])) {
        $type = $this->_columnTypes[$columnNameIdentifier];
    }

    $stmt->bindValue($paramIndex<ins></ins>, $idVal, $type);
}

I hope that you will have time to take a look in to that problem soon as it is important for my project. Otherwise great work so far with the "ORM" :)

Have a nice day,
Victor

Originally created by @doctrinebot on GitHub (Aug 3, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user vigor_bg: Hi there, I am using "Class Table Inheritance" and this are my entities. ``` **** * @Entity * @Table (name="Vehicles") * @InheritanceType ("JOINED") * @DiscriminatorColumn (name="vehicleClass", type="string") * @DiscriminatorMap ({"own"="OwnCar", "renta"="RentedCar"}) */ class Vehicle { /**** * @Id * @Column (name="vehicleID", type="integer") */ protected $vehicleID; /**** * @Id * @Column (name="dateFrom", type="datetime") */ protected $dateFrom; ......... } ``` ``` /**** * @Table (name="OwnCars") * @Entity (repositoryClass="OwnCarRepo") */ class OwnCars*Model_Entity_OwnCar extends OwnCars_Model_Entity*Vehicle { } ``` As you can see i am using composed id keys. The problem that i get is when building the insert statement the value for the second key which is type datetime is not transformed to date transformed but cast to integer and in the data base i got inserted value of 0000-00-00 00:00:00 instead of the date that i have given. After i did a bit of debugging i found the problem to be in the "Doctrine\ORM\Persisters\JoinedSubclassPersister" on line 163. ``` foreach ((array) $id as $idVal) { $stmt->bindValue($paramIndex<ins></ins>, $idVal); } ``` As you can see when you are binding the values for the subtable ids you are not giving the type for the id. So for me to work i did a quick fix: ``` foreach ((array) $id as $columnNameIdentifier => $idVal) { /**** * Fix untyped join inherited table. * All identifiers was typed now. */ $type = \PDO::PARAM_STR; if (isset($this->_columnTypes[$columnNameIdentifier])) { $type = $this->_columnTypes[$columnNameIdentifier]; } $stmt->bindValue($paramIndex<ins></ins>, $idVal, $type); } ``` I hope that you will have time to take a look in to that problem soon as it is important for my project. Otherwise great work so far with the "ORM" :) Have a nice day, Victor
admin added the Improvement label 2026-01-22 13:21:10 +01:00
admin closed this issue 2026-01-22 13:21:10 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 3, 2011):

@doctrinebot commented on GitHub (Aug 3, 2011): - is required for [DDC-1320: Ship Immutable date time with Doctrine Common, use in ORM - Should implement __toString()](http://www.doctrine-project.org/jira/browse/DDC-1320)
Author
Owner

@doctrinebot commented on GitHub (Aug 6, 2011):

Comment created by @beberlei:

Even if we fixed that it wouldn't work to have a DateTime as primary key. Since PK values need to be "stringable".

@doctrinebot commented on GitHub (Aug 6, 2011): Comment created by @beberlei: Even if we fixed that it wouldn't work to have a DateTime as primary key. Since PK values need to be "stringable".
Author
Owner

@doctrinebot commented on GitHub (Aug 6, 2011):

Comment created by @beberlei:

Changed to improvement and link to DDC-1320

@doctrinebot commented on GitHub (Aug 6, 2011): Comment created by @beberlei: Changed to improvement and link to [DDC-1320](http://www.doctrine-project.org/jira/browse/DDC-1320)
Author
Owner

@doctrinebot commented on GitHub (Sep 5, 2011):

Comment created by @guilhermeblanco:

Even though DateTime would be solved in a different way, I think the patch must be applied specially because the identifier can be anything else, including a user customized type.

I fixed this issue by commit: 666691f84f

@doctrinebot commented on GitHub (Sep 5, 2011): Comment created by @guilhermeblanco: Even though DateTime would be solved in a different way, I think the patch must be applied specially because the identifier can be anything else, including a user customized type. I fixed this issue by commit: https://github.com/doctrine/doctrine2/commit/666691f84fd5a48d0eb6af7e93b83c2651555e61
Author
Owner

@doctrinebot commented on GitHub (Sep 5, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Sep 5, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Sep 25, 2011):

Comment created by @beberlei:

Set to 2.2-DEV as one thing is unclear for me, see commit comment.

@doctrinebot commented on GitHub (Sep 25, 2011): Comment created by @beberlei: Set to 2.2-DEV as one thing is unclear for me, see commit comment.
Author
Owner

@doctrinebot commented on GitHub (Oct 31, 2011):

Comment created by @beberlei:

Merged into 2.1.x

@doctrinebot commented on GitHub (Oct 31, 2011): Comment created by @beberlei: Merged into 2.1.x
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1651