-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
I'm trying to utilize fastapi + sqlalchemy which uses pydantic. My sqlalchemy column type is BINARY(16) mapping to that exact type in a MariaDB/MySQL database:
uuid = Column(BINARY(16), nullable=False, unique=True)
In pydantic I'm defining as:
uuid: UUID
I get an error thrown that the "value is not a valid uuid (type=type_error.uuid)".
I've cloned pydantic and included a new test for the following:
('uuid_check', b'\x12\x34\x56\x78' * 4, UUID('12345678-1234-5678-1234-567812345678')),
...which fails using your current code. You can find the test byte string above in the official python documentation. I've made a modification in validators to fallback to utilizing the bytes argument in UUID, and then the tests pass. I'm hoping you'd be interested in this fix, as its currently preventing us from using pydantic for a large project refactor. Thank you.