generated from daniil-berg/boilerplate-py
Minor changes
This commit is contained in:
parent
a64708dedd
commit
20272c4b4a
@ -54,7 +54,7 @@ def from_sqla(db_model: Type[DeclarativeMeta], incl_many_to_one: bool = True, in
|
||||
config: Type[BaseConfig] = OrmConfig, exclude: Container[str] = (),
|
||||
add_fields: dict[str, FieldDef] = None):
|
||||
assert isinstance(db_model, DeclarativeMeta)
|
||||
assert not (incl_one_to_many and incl_many_to_one)
|
||||
assert not (incl_one_to_many and incl_many_to_one), "Pydantic is unable to handle the circular relationship"
|
||||
fields = {}
|
||||
for attr in inspect(db_model).attrs:
|
||||
if attr.key in exclude:
|
||||
|
@ -9,7 +9,6 @@ from orm2pydantic.sqla import from_sqla
|
||||
|
||||
|
||||
ORMBase = declarative_base()
|
||||
engine = create_engine("sqlite://")
|
||||
|
||||
|
||||
def default_factory() -> str: return '1'
|
||||
@ -65,11 +64,12 @@ class Address(AbstractBase):
|
||||
|
||||
|
||||
def main_test() -> None:
|
||||
engine = create_engine("sqlite://")
|
||||
AbstractBase.metadata.create_all(engine)
|
||||
|
||||
from_sqla(StateProvince)
|
||||
from_sqla(City)
|
||||
from_sqla(Street)
|
||||
_PydanticStateProvince = from_sqla(StateProvince)
|
||||
_PydanticCity = from_sqla(City)
|
||||
_PydanticStreet = from_sqla(Street)
|
||||
_PydanticAddress = from_sqla(Address)
|
||||
|
||||
with Session(engine) as session:
|
||||
|
Loading…
Reference in New Issue
Block a user