You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, psqlpy supports using the row_factory method for mapping results to Python objects like Pydantic models. However, it does not support mapping to TypedDict, which is a common construct used for type-safe dictionary-like objects in Python.
Steps to reproduce:
Create a TypedDict class:
from typing import TypedDict
class MyTypedDict(TypedDict):
id: int
name: str
2. Use the row_factory to map results to this TypedDict:
def to_class(class_):
def to_class_inner(row):
return class_(**row)
return to_class_inner
conn_result.row_factory(row_factory=to_class(MyTypedDict))
the code raises a TypeError.
The text was updated successfully, but these errors were encountered:
Currently, psqlpy supports using the row_factory method for mapping results to Python objects like Pydantic models. However, it does not support mapping to TypedDict, which is a common construct used for type-safe dictionary-like objects in Python.
Steps to reproduce:
from typing import TypedDict
class MyTypedDict(TypedDict):
id: int
name: str
2. Use the row_factory to map results to this TypedDict:
def to_class(class_):
def to_class_inner(row):
return class_(**row)
return to_class_inner
conn_result.row_factory(row_factory=to_class(MyTypedDict))
the code raises a TypeError.
The text was updated successfully, but these errors were encountered: