finish of refactor
This commit is contained in:
@ -87,13 +87,10 @@ def sqlalchemy_columns_from_model_fields(
|
|||||||
|
|
||||||
return pkname, columns
|
return pkname, columns
|
||||||
|
|
||||||
def populate_default
|
|
||||||
|
|
||||||
def populate_pydantic_default_values(attrs: Dict) -> Dict:
|
def populate_default_field_value(
|
||||||
for field, type_ in attrs["__annotations__"].items():
|
type_: Type[BaseField], field: str, attrs: dict
|
||||||
if issubclass(type_, BaseField):
|
) -> dict:
|
||||||
if type_.name is None:
|
|
||||||
type_.name = field
|
|
||||||
def_value = type_.default_value()
|
def_value = type_.default_value()
|
||||||
curr_def_value = attrs.get(field, "NONE")
|
curr_def_value = attrs.get(field, "NONE")
|
||||||
if curr_def_value == "NONE" and isinstance(def_value, FieldInfo):
|
if curr_def_value == "NONE" and isinstance(def_value, FieldInfo):
|
||||||
@ -103,6 +100,15 @@ def populate_pydantic_default_values(attrs: Dict) -> Dict:
|
|||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
||||||
|
def populate_pydantic_default_values(attrs: Dict) -> Dict:
|
||||||
|
for field, type_ in attrs["__annotations__"].items():
|
||||||
|
if issubclass(type_, BaseField):
|
||||||
|
if type_.name is None:
|
||||||
|
type_.name = field
|
||||||
|
attrs = populate_default_field_value(type_, field, attrs)
|
||||||
|
return attrs
|
||||||
|
|
||||||
|
|
||||||
def get_pydantic_base_orm_config() -> Type[BaseConfig]:
|
def get_pydantic_base_orm_config() -> Type[BaseConfig]:
|
||||||
class Config(BaseConfig):
|
class Config(BaseConfig):
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|||||||
Reference in New Issue
Block a user