|
1 | 1 | """This module is a CRUD interface between resource managers and the sqlalchemy ORM""" |
2 | 2 | import logging |
3 | | -from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, Type |
| 3 | +from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple, Type |
4 | 4 |
|
5 | 5 | from sqlalchemy import delete, func, select |
6 | 6 | from sqlalchemy.exc import DBAPIError, IntegrityError, NoResultFound |
|
32 | 32 | get_related_schema, |
33 | 33 | ) |
34 | 34 | from fastapi_jsonapi.schema_base import RelationshipInfo |
35 | | -from fastapi_jsonapi.schema_builder import FieldConfig, TransferSaveWrapper |
36 | 35 | from fastapi_jsonapi.splitter import SPLIT_REL |
37 | 36 | from fastapi_jsonapi.utils.sqla import get_related_model_cls |
38 | 37 |
|
@@ -185,38 +184,6 @@ async def apply_relationships(self, obj: TypeModel, data_create: BaseJSONAPIItem |
185 | 184 | # todo: relation name may be different? |
186 | 185 | setattr(obj, relation_name, related_data) |
187 | 186 |
|
188 | | - def _unwrap_field_config(self, extra: Dict): |
189 | | - field_config_wrapper: TransferSaveWrapper = extra.get("field_config") |
190 | | - |
191 | | - if field_config_wrapper: |
192 | | - return field_config_wrapper.field_config |
193 | | - |
194 | | - return FieldConfig() |
195 | | - |
196 | | - def _apply_client_generated_id( |
197 | | - self, |
198 | | - data_create: BaseJSONAPIItemInSchema, |
199 | | - model_kwargs: dict, |
200 | | - ): |
201 | | - """ |
202 | | - :param data_create: the data validated by pydantic. |
203 | | - :param model_kwargs: the data validated by pydantic. |
204 | | - """ |
205 | | - if data_create.id is None: |
206 | | - return model_kwargs |
207 | | - |
208 | | - extra = data_create.__fields__["id"].field_info.extra |
209 | | - if extra.get("client_can_set_id"): |
210 | | - id_value = data_create.id |
211 | | - field_config = self._unwrap_field_config(extra) |
212 | | - |
213 | | - if field_config.cast_type: |
214 | | - id_value = field_config.cast_type(id_value) |
215 | | - |
216 | | - model_kwargs["id"] = id_value |
217 | | - |
218 | | - return model_kwargs |
219 | | - |
220 | 187 | async def create_object(self, data_create: BaseJSONAPIItemInSchema, view_kwargs: dict) -> TypeModel: |
221 | 188 | """ |
222 | 189 | Create an object through sqlalchemy. |
|
0 commit comments