DDC-704: Inheritance-type with no discriminator-column results in SQL Error #867

Closed
opened 2026-01-22 12:53:14 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 20, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user cmealey:

On an entity (XML mapping atleast) if there is an inheritance-type set but no discriminator-column(s) set the resulting query will have an extra comma at the end of the field list or occasionally (based on inheritance-type) a table alias without a fieldname.

The correct solution would be to throw an exception during the parsing of the mapping that would indicate the inheritance-type is set but no discriminator-columns exist.

Originally created by @doctrinebot on GitHub (Jul 20, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user cmealey: On an entity (XML mapping atleast) if there is an inheritance-type set but no discriminator-column(s) set the resulting query will have an extra comma at the end of the field list or occasionally (based on inheritance-type) a table alias without a fieldname. The correct solution would be to throw an exception during the parsing of the mapping that would indicate the inheritance-type is set but no discriminator-columns exist.
admin added the Bug label 2026-01-22 12:53:14 +01:00
admin closed this issue 2026-01-22 12:53:16 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jul 20, 2010):

Comment created by cmealey:

Moving this from Major to Minor as a correctly mapped entity works fine, the bug is in the error reporting, not the functionality

@doctrinebot commented on GitHub (Jul 20, 2010): Comment created by cmealey: Moving this from Major to Minor as a correctly mapped entity works fine, the bug is in the error reporting, not the functionality
Author
Owner

@doctrinebot commented on GitHub (Aug 8, 2010):

Comment created by @beberlei:

Implemented better validation

@doctrinebot commented on GitHub (Aug 8, 2010): Comment created by @beberlei: Implemented better validation
Author
Owner

@doctrinebot commented on GitHub (Aug 8, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Aug 8, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Aug 16, 2010):

Comment created by mridgway:

I can't help but feel that the validation should be implemented outside of the metadata drivers. To me the driver shouldn't require the discriminator map to be present because it limits the ability to add discriminators in other ways.

Example:

I use annotations for my models, but I don't set the discriminator maps using the annotations driver, instead I use the loadClassMetadata event to fill in the discriminatorMap from configs or a database. Perhaps this is a job for a custom metadata driver, but I still can't help but feel that the metadata driver shouldn't be the one making these validations, it should be when you try to use the inheritance-mapped model.

Edit: To clarify the situation: I now get mappingException::missingDiscriminatorMap exception because my model annotations don't have a @DiscriminatorMap, but they would be loaded with the loadClassMetadata function.

@doctrinebot commented on GitHub (Aug 16, 2010): Comment created by mridgway: I can't help but feel that the validation should be implemented outside of the metadata drivers. To me the driver shouldn't require the discriminator map to be present because it limits the ability to add discriminators in other ways. Example: I use annotations for my models, but I don't set the discriminator maps using the annotations driver, instead I use the loadClassMetadata event to fill in the discriminatorMap from configs or a database. Perhaps this is a job for a custom metadata driver, but I still can't help but feel that the metadata driver shouldn't be the one making these validations, it should be when you try to use the inheritance-mapped model. Edit: To clarify the situation: I now get mappingException::missingDiscriminatorMap exception because my model annotations don't have a @DiscriminatorMap, but they would be loaded with the loadClassMetadata function.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#867