From 11fcded97a2cd8e541988d15fe4faba489598b04 Mon Sep 17 00:00:00 2001 From: Ruslan Bel'kov Date: Mon, 4 Sep 2023 10:11:18 +0300 Subject: [PATCH] fix(storage): exclude auto loading ownerships field from models --- src/schemas/event_groups.py | 2 +- src/schemas/tags.py | 4 ++-- src/storages/sql/__mixin__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/schemas/event_groups.py b/src/schemas/event_groups.py index 14ad93c..ab63afe 100644 --- a/src/schemas/event_groups.py +++ b/src/schemas/event_groups.py @@ -38,7 +38,7 @@ class ViewEventGroup(BaseModel): name: Optional[str] = None description: Optional[str] = None tags: list["ViewTag"] = Field(default_factory=list) - ownerships: list["Ownership"] = Field(default_factory=list) + # ownerships: list["Ownership"] = Field(default_factory=list) @validator("tags", pre=True, always=True) def _validate_tags(cls, v): diff --git a/src/schemas/tags.py b/src/schemas/tags.py index 8307931..7e700f5 100644 --- a/src/schemas/tags.py +++ b/src/schemas/tags.py @@ -3,7 +3,7 @@ import json from typing import Optional -from pydantic import BaseModel, validator, Json, Field +from pydantic import BaseModel, validator, Json from src.schemas.ownership import Ownership @@ -28,7 +28,7 @@ class ViewTag(BaseModel): name: Optional[str] = None satellite: Optional[dict] = None - ownerships: list[Ownership] = Field(default_factory=list) + # ownerships: list[Ownership] = Field(default_factory=list) @validator("satellite", pre=True, always=True) def _validate_satellite(cls, v): diff --git a/src/storages/sql/__mixin__.py b/src/storages/sql/__mixin__.py index 564289c..dae89e0 100644 --- a/src/storages/sql/__mixin__.py +++ b/src/storages/sql/__mixin__.py @@ -59,7 +59,7 @@ class Ownership(Base): @declared_attr def ownerships(cls) -> Mapped[list["Ownership"]]: - return relationship(cls.Ownership, lazy="selectin", cascade="all, delete-orphan") + return relationship(cls.Ownership, cascade="all, delete-orphan") return Mixin