-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Identifier name isn't allowed to be custom. #2096
Comments
At https://github.com/doctrine/mongodb-odm/blob/master/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1953 the dumped value of
|
IIRC field named |
After some research, I tend to agree with you @malarzm . I think this issue should be renamed appropriately into a task to disable custom fieldnames for IDs. |
Identifier names in the database are fixed to the In your case, you can have a |
@alcaeus , that IS the problem: I can't have field named |
@alcaeus , I just checked your PR, and I believe change in XMLDriver is fixing the problem I described above. |
I just wanted to make sure you don't have wrong expectations because of this:
With the |
Yea, updated the original post above, striking through some wordings. So yea, current expectation is the fix in document class. |
Fix wrong handling of custom identifier names
Bug Report
Summary
In XML configuration, attempting to give custom field_name to IDs doesn't work. ClassMetadata fails.
<id field-name="uuid" strategy="UUID" type="bin_uuid" />
Current behavior
<id field-name="uuid" strategy="UUID" type="bin_uuid" />
Field-names
bothin document class,and in Db areis "uuid". Yet, code here:https://github.com/doctrine/mongodb-odm/blob/master/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1953
resolves
$mapping['fieldName']
value toid
instead of intendeduuid
.How to reproduce
Use this as ID field configuration in your XML document odm file:
<id field-name="uuid" strategy="UUID" type="bin_uuid" />
Expected behavior
For ClassMetadata to have
$mapping['fieldName']
to actually be equal to$mapping['field_name']
(the latter having the correct value), being equal touuid
notid
, as this example expects.UPDATE: We can't have custom identifier name in Db, it is always
_id
. This was realized to be the case and the fact established in our chat below.The text was updated successfully, but these errors were encountered: