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

Date type does not decompose correctly #168

Open
prutheus opened this issue Apr 23, 2024 · 0 comments
Open

Date type does not decompose correctly #168

prutheus opened this issue Apr 23, 2024 · 0 comments

Comments

@prutheus
Copy link

prutheus commented Apr 23, 2024

I have a model definition:

from pydantic_extra_types.pendulum_dt import Date

class TypeValuePair(BaseModel):
    """
    type: value
    """

    type: str = Field(...)
    value: str = Field(...)

    class Config:
        """
        config
        """

        populate_by_name = True
        json_schema_extra = {
            "example": {"type": "Subject Area", "value": "Drainage Sewage"}
        }

class Transaction(BaseModel):
    """
    transac, note, date
    """

    transac: TypeValuePair = Field(...)
    note: TypeValuePair = Field(...)
    date: Date = Field(...)

    class Config:
        """
        config
        """

        populate_by_name = True
        arbitrary_types_allowed = True
        json_schema_extra = {
            "example": {
                "transac": {
                    "type": "terminologyManagementTransactions",
                    "value": "origination",
                },
                "note": {"type": "responsibility", "value": "joanna.schroer"},
                "date": "2015-03-09",
            }
        }

When I want to create an object of this model, it is not correctly decomposed to the pendulum Date type:

Transaction(transac=ml.TypeValuePair(type="", value=""), note=ml.TypeValuePair(type="", value=""), date="2015-03-09")

Returns:

Transaction(transac=TypeValuePair(type='', value=''), note=TypeValuePair(type='', value=''), date=datetime.date(2015, 3, 9))

Where the date parameter is type datetime.date instead of pendulum.Date. If I use DateTime instead of Date it works fine. What is the issue?

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