mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #10598] Support not Insertable/Updateable columns for entities with JOINED inheritance type
#12479
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/10598
State: closed
Merged: Yes
Fix for https://github.com/doctrine/orm/issues/9467 when insert and update entity with
joinedinheritance + update values from database#[InheritanceType('JOINED')]attribute process byJoinedSubclassPersister, according toUnitOfWork::getEntityPersister():da9b9de590/lib/Doctrine/ORM/UnitOfWork.php (L3227-L3228)getInsertColumnList()without excludingnotInsertablecolumns like parent do:da9b9de590/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php (L1478)so when it use prepared sql-statement with parameters prepared by parent (
AbstractEntityInheritancePersister::prepareInsertData()reuseBasicEntityPersister::prepareInsertData()reuseBasicEntityPersister::prepareUpdateData()with$isInsertmode):da9b9de590/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php (L640-L659)we get error from database, e.g. postgresql:
JoinedSubclassPersister::getInsertColumnList(). There is no such error for update queries, because parent methods used inJoinedSubclassPersister::update():BasicEntityPersister::prepareUpdateData()andBasicEntityPersister::updateTable().notInsertable|notUpdatable|version) after flush -JoinedSubclassPersister::assignDefaultVersionAndUpsertableValues():da9b9de590/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php (L548-L555)ClassMetadataInfo::$requiresFetchAfterChange) in both cases (executeInserts() and update()) doesnt inherited from entity parent-class. This fixed by tracking of parent mappings inClassMetadataInfo::addInheritedFieldMapping()like it done for child entity inmapField()(may be add setter for factory):da9b9de590/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (L2814-L2820)JoinedSubclassPersister::fetchVersionAndNotUpsertableValues()- where added join (reuseJoinedSubclassPersister::getJoinSql()) and column aliases. Make parentextractIdentifierTypes()and$identifierFlattenermake them protected.insert()method to avoidLengthException('Unexpected empty result for database query.').JoinedInheritanceRootentity, with children for each case andJoinedInheritanceChildto test root entity columns. Declare database default column values to avoid platform-specificcolumnDefinition. Usegenerated: 'ALWAYS'in hope to obtain error fromupdate()method