dinao 2.2.0.dev180__tar.gz → 2.2.0.dev182__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dinao-2.2.0.dev180/dinao.egg-info → dinao-2.2.0.dev182}/PKG-INFO +1 -1
- dinao-2.2.0.dev182/dinao/__version__.py +2 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/binding/mappers.py +17 -2
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182/dinao.egg-info}/PKG-INFO +1 -1
- dinao-2.2.0.dev180/dinao/__version__.py +0 -2
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/AUTHORS +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/LICENSE +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/README.md +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/__init__.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/__init__.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/base.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/errors.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/mariadb.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/mysql.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/postgres/__init__.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/postgres/asyncpg.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/postgres/base.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/postgres/psycopg2.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/postgres/psycopg3.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/sqlite/__init__.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/sqlite/aiosqlite.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/sqlite/base.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/backend/sqlite/stdlib.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/binding/__init__.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/binding/binders/__init__.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/binding/binders/async_.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/binding/binders/base.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/binding/binders/sync.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/binding/errors.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/binding/templating.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao/mung.py +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao.egg-info/SOURCES.txt +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao.egg-info/dependency_links.txt +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao.egg-info/requires.txt +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/dinao.egg-info/top_level.txt +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/pyproject.toml +0 -0
- {dinao-2.2.0.dev180 → dinao-2.2.0.dev182}/setup.cfg +0 -0
|
@@ -69,10 +69,25 @@ class ClassRowMapper(DictRowMapper):
|
|
|
69
69
|
class SingleValueRowMapper(RowMapper):
|
|
70
70
|
"""Implements a row mapper for a primitive type."""
|
|
71
71
|
|
|
72
|
+
def __init__(self, mapped_type: typing.Type):
|
|
73
|
+
"""Construct a single value row mapper that casts the result to the target type.
|
|
74
|
+
|
|
75
|
+
:param mapped_type: the primitive type to cast the result to
|
|
76
|
+
"""
|
|
77
|
+
self._mapped_type = mapped_type
|
|
78
|
+
|
|
72
79
|
def __call__(self, row: typing.Tuple, description: typing.Tuple[ColumnDescriptor, ...]): # noqa: D102
|
|
73
80
|
if len(row) > 1:
|
|
74
81
|
raise TooManyValuesError(f"Too many values, expected 1, got {len(row)}")
|
|
75
|
-
|
|
82
|
+
value = row[0]
|
|
83
|
+
if value is None:
|
|
84
|
+
return None
|
|
85
|
+
if isinstance(value, self._mapped_type):
|
|
86
|
+
return value
|
|
87
|
+
# SQLite special case, we should consider better adapter handling
|
|
88
|
+
if self._mapped_type is datetime and isinstance(value, str):
|
|
89
|
+
return datetime.fromisoformat(value)
|
|
90
|
+
return self._mapped_type(value)
|
|
76
91
|
|
|
77
92
|
|
|
78
93
|
def get_row_mapper(row_type: typing.Type) -> typing.Optional[RowMapper]:
|
|
@@ -92,7 +107,7 @@ def get_row_mapper(row_type: typing.Type) -> typing.Optional[RowMapper]:
|
|
|
92
107
|
elif row_type in DICT_GENERICS:
|
|
93
108
|
return DictRowMapper()
|
|
94
109
|
elif row_type in NATIVE_SINGLE:
|
|
95
|
-
return SingleValueRowMapper()
|
|
110
|
+
return SingleValueRowMapper(row_type)
|
|
96
111
|
# Exclude typing special forms that look like classes in Python 3.14+
|
|
97
112
|
# Bare Union/Optional without type parameters cannot be mapped
|
|
98
113
|
elif row_type in TYPING_SPECIAL_FORMS:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|