Skip to content

'datetime.date' object has no attribute 'date' #38

Closed
@kevnoli

Description

@kevnoli

I'm building an API with FastAPI that connects to a Firebird 3.0.4 database.

For an endpoint that accepts a model with a date field and tries to update a table with that date, I'm getting the following error message:

File "[...]/site-packages/firebird/driver/core.py", line 179, in _encode_timestamp
    return _util.encode_date(v.date()).to_bytes(4, 'little') + _util.encode_time(datetime.time()).to_bytes(4, 'little')
AttributeError: 'datetime.date' object has no attribute 'date'

I believe that this code could be fixed by removing the call to date()

if isinstance(v, datetime.date):
    return _util.encode_date(v).to_bytes(4, 'little') + _util.encode_time(datetime.time()).to_bytes(4, 'little')
raise ValueError("datetime.datetime or datetime.date expected")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions