mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Validate schema command isn't handling entities with attributes #6889
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 @oojacoboo on GitHub (Dec 15, 2021).
Bug Report
Summary
I should start by saying that we're in the process of updating our entities to use attributes instead of annotations. This is going to be a gradual process. Therefore, we need to support both, attributes and annotations, until that migration has completed. To do this, we've implemented a custom Mapping\Driver, as seen below:
Current behavior
This, when being used by the EntityManager (registered as the MetadataDriverImpl), works fine with the
orm:generate-proxiescommand. However, when running theorm:validate-schema, it's unable to validate, failing to find the class that's defined by attributes.How to reproduce
Have one class defined by attributes, the others by annotations, and run
orm:validate-schemaExpected behavior
Validation should use the same logic as generate to allow the use of both annotations and attributes.
@oojacoboo commented on GitHub (Dec 15, 2021):
It's also worth noting that this dual Driver approach is breaking the discriminator mapping entities.
Maybe some general advice around this approach would be valuable. I apologize if this has been discussed before somewhere. I wasn't able to find much available. The mapping class inspiration I found at https://github.com/helvete/hybrid_mapping_driver.
@beberlei commented on GitHub (Dec 18, 2021):
This is most likely due to the implementation of the driver and not a bug in Doctrine. I recommend that you look at the
DriverChainand implement a new driver based off that with a whitelist of classes that are attribute-based instead of the namespace comparison. Please open the issue again if that didn't help.@oojacoboo commented on GitHub (Dec 19, 2021):
If anyone comes across this post looking for a solution, we've dropped the plan to support both annotation and attributes and instead used the doctrine rectors to do a full refactor.
https://github.com/rectorphp/rector
Using this configuration