mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
The discriminator column "key" is missing - initialize collection
#6417
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?
Originally created by @ybenhssaien on GitHub (Mar 2, 2020).
Bug Report
Summary
Filter on a collection of entities with a reserved MySQL word as Mapping column generates an exception when initializing the collection after calling filter.
Current behavior
How to reproduce
Context
mission+mission_ateaMission(for table mission) +MissionAtea(for table mission_atea) +MissionAteaCommentaire(inherits from MissionAtea with discrimnation columnkey)MissiontoMissionAtea) [attribut : extraData)Database :

Call
Mission::getExtraDataByKey('commentaire')Expected behavior
Return the mapped entities (MissionAteaCommentaire)
@ybenhssaien commented on GitHub (Mar 2, 2020):
Problem source : Checking the existence of
keyinhydrateColumnInfo()method onAbstractHydratorclass while storing`key`instead :@beberlei commented on GitHub (Mar 2, 2020):
My first comment was wrong, this looks like indeed quoted discriminator columns is not working.
Honestly I don't see us fixing this anytime soon, because its probably more complex work. What you can do is see
ClassMetadataInfohow field mapping and other tihngs set a booelanquoted = truewhen they detect the escape character being used and then other places using theClassMetadataInfo::$discriminatorColumnfor SQL generation to check for quoted.It seems
QuoteStrategyhas no support for discriminator columns either, this would make sense as well to add.All in all, your best solution would be not to use an SQL keyword as disciminrator column name. Hopefully thats possible.
@ybenhssaien commented on GitHub (Mar 3, 2020):
Thanks @beberlei
Actually is mentionned in the documentation : https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/basic-mapping.html#quoting-reserved-words
But, using this strategy, impact the generated select statement as the concatenation is done one the quoted column

SELECT ..... , a3_.`key` AS `key`_70, .. FROM:@ybenhssaien commented on GitHub (Mar 3, 2020):
Everyone who is wondering about how this is done on Symfony > 4.0 app, just edit the
config/packages/doctrine.yaml