Navigation Menu

Skip to content
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

Can a discriminator field ever trigger a duplicate field mapping exception? #227

Closed
jmikola opened this issue Jan 9, 2012 · 1 comment
Closed

Comments

@jmikola
Copy link
Member

jmikola commented Jan 9, 2012

We have this method in ClassMetadataInfo:

public function setDiscriminatorField($discriminatorField)
{
    if ( ! isset($discriminatorField['name']) && isset($discriminatorField['fieldName'])) {
        $discriminatorField['name'] = $discriminatorField['fieldName'];
    }
    if (isset($this->fieldMappings[$discriminatorField['name']])) {
        throw MongoDBException::duplicateFieldMapping($this->name, $discriminatorField['name']);
    }
    $this->discriminatorField = $discriminatorField;
}

Based on how annotations are loaded, the discriminator annotations are processed at the class doc-block level and presumably before any field-level annotations. Therefore, I don't think any field mappings would exist at the time this method is called.

Perhaps it's more relevant for metadata defined in PHP, XML, and YAML?

The example in the annotations reference actually has a field mapping declared on the property corresponding to the discriminator field. That's the very thing I expect would trigger this exception, if the same example was ported to XML or YAML.

@jmikola
Copy link
Member Author

jmikola commented Jan 22, 2014

Discriminators were recently refactored in #720 and the exception was kept.

@jmikola jmikola closed this as completed Jan 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant