litestar-org/polyfactory

Bug: Unsupported type: <class 'odmantic.bson._datetime'>

Closed this issue · 2 comments

Description

Trying to build a factory for an odmantic model with datetime fields raise a ParameterException with the message in the title. That's because odmantic replaces datetime with a custom subclass.

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

"In the format of: `![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)`"

Logs

No response

Litestar Version

2.0.0

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Hi, please email there add a PR with a failing test or post a failing example

Just adding a created_on: datetime field on any of MyModel, MyEmbeddedDocument or OtherEmbeddedDocument in test_odmantic_factory reproduces it.

I have a PR that fixes it (along with all other bson types) for odmantic.Model but it still fails for odmantic.EmbeddedModel due to a different issue: the selected factory for odmantic.EmbeddedModel is the (pydantic) ModelFactory instead of OdmanticModelFactory; both factories return True for is_supported_type(model) but just the first one is picked here.