mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-515: CLI Task: validate-mapping #642
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 @doctrinebot on GitHub (Apr 12, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user romanb:
There should be a CLI task "validate-mapping" or similar that reads in the metadata of all configured, mapped classes and processes them one-by-one, looking for errors in the mapping. For example, it is easy to detect that way when there is an association mapped with mappedBy but the other side does not have inversedBy specified (or there is not even another side...) . We can not make such strict validations during runtime for performance reasons, so a specific CLI task can be a great help during development for troubleshooting.
@doctrinebot commented on GitHub (Apr 12, 2010):
Comment created by @beberlei:
We also need this to check in development if the current database schema equals the current metadata mapping. Possibly extracting all the logic of this into a Service Object so that users can include this in Phing or similar build processes.
@doctrinebot commented on GitHub (Apr 16, 2010):
Comment created by romanb:
I interpret that as you volunteering ;)
@doctrinebot commented on GitHub (Apr 30, 2010):
Comment created by mjh_ca:
It would also be helpful if the task could look for lifecycle callback annotations in the methods and raise a warning if the class does not have a @HasLifeCycleCallbacks annotation.
@doctrinebot commented on GitHub (May 2, 2010):
Comment created by @beberlei:
Hm this last one is a bit complicated, one would need to check if the annotation driver is used, instantiate your own reader and check for this error.
@doctrinebot commented on GitHub (May 3, 2010):
Comment created by romanb:
In the context of DDC-567 it would also be nice to validate that all referenced column names are primary key columns.
ps. If anyone is curious why referencedColumnName then not always automatically points to the primary key column of the other class, its just not doable in an efficient way I think. referencedColumnName defaults to the hardcoded "id" name, because each class metadata must be able to be loaded independently without loading others (inheritance being an exception). If we start "guessing" default values by looking at other classes, we quickly load the metadata for huge parts (or all) of the mapping of the domain model on each request. At least during development without a persistent cache this would be a major pain and slowdown.
@doctrinebot commented on GitHub (May 3, 2010):
Comment created by @beberlei:
@Roman - I just checked for "referencedColumnName" in the code, aswell as for their descendants during metadata ClassMetadata generation.
It seems they are not used "that" much throughout the code, would a lookuup to the targetEntity work? We could get rid of this attribute then...
@doctrinebot commented on GitHub (May 3, 2010):
Comment created by romanb:
@Benjamin: We can not get rid of it anyway because of composite keys I think.
Like I said, a lookup on the targetEntity would potentially trigger a huge cascade of metadata loading throughout the whole domain model. Then the targetEntity has associations and so on and so on.
@doctrinebot commented on GitHub (May 11, 2010):
Comment created by @beberlei:
This was implemented in the latest commit.
@doctrinebot commented on GitHub (May 11, 2010):
Issue was closed with resolution "Fixed"