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

Support enum-type for id field in XML mapping #11280

Open
tmihalicka opened this issue Feb 20, 2024 · 5 comments
Open

Support enum-type for id field in XML mapping #11280

tmihalicka opened this issue Feb 20, 2024 · 5 comments

Comments

@tmihalicka
Copy link
Contributor

tmihalicka commented Feb 20, 2024

Bug Report

Q A
BC Break no
Version 2.18.1 / 3.0.1

Summary

Missing support for enum-type in XML mapping

yaml, annotations and attibutes support enumType for Id field mapping but this is missing from xml mapping, and mising this option in xsd schema too.

Current behavior

It's not possible to add enum-type to XML mapping for Id field

How to reproduce

Try add enum-type to id field in xml mapping for example:

<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                          https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="Offer" table="offer">
        <id name="id" type="OfferId" column="id"/>
        <id name="type" type="string" enum-type="OfferType" column="type"/>
    </entity>
</doctrine-mapping>

Expected behavior

Possible declare enum-type for Id field in xml mapping.

@kimhemsoe
Copy link
Member

Works for me with FQCN. Btw may i ask why you need to specify? ORM can read the type from entity.

@tmihalicka
Copy link
Contributor Author

tmihalicka commented Feb 20, 2024

And it's works for you in XML becuase XSD schema is missing enum-type for Id field?

@tmihalicka
Copy link
Contributor Author

For example this is annotation and attribute example

    /**
     * @ORM\Id()
     * @ORM\Column(type="string", enumType=Unit::class)
     */
    #[Id]
    #[Column(type: 'string', enumType: Unit::class)]
    public Unit $unit;

But for XML there is no way how to define enum-type for Id field

@kimhemsoe
Copy link
Member

Sorry miss read. Just checked xml driver and it seems to have support, but the xsd never got updated.

What you can now as a workaround is either disable xsd validation until someone makes a PR or remove the enum-type from the xml and let ORM read the type via reflection.

In your example you can remove "enumType=Unit::class" and "enumType: Unit::class" and it will work.

@tmihalicka
Copy link
Contributor Author

Sure i will open PR with fixed XSD mapping :)

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

2 participants