Похожие чаты

Всем привет такой вопрос, я делаю использую доменые модели и

маплю их на одели алхимии

Получается что-то вроде:
@dataclass
class House:
id: str
section: Section | None = field(default=None)

И вот в чем прикол у меня section это релейшен который мне не нужен в одном из кейсов соответственно я его не загружаю, однако если я попробую к примеру распечатать модель, то получу ошибку:
sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <House at 0x130160af0> is not bound to a Session; lazy load operation of attribute 'section' cannot proceed (Background on this error at: https://sqlalche.me/e/20/bhk3)

Однако по логике у меня все верно. Сессия закрыта, а подгружать section не надо тк он не требуется. Есть ли какой-то вариант решения? Сейчас вижу только что-то вроде этого:
@property
def section(self) -> Section:
return self.section

4 ответов

5 просмотров

field(..., repr=False) по идее

Matvei-Bekishev Автор вопроса
Matvei Bekishev
Не, не помогло

Вероятно предпочел бы сделать разные модели, или смирился с избыточной загрузкой данных. Странно если пытается прочитать section при отключенном repr

Matvei-Bekishev Автор вопроса
Айван
Вероятно предпочел бы сделать разные модели, или с...

Я бы тоже сделал разные модели, но это задача на рефакторинг еще большей части сервиса, а я и так слишком многое изменяю после постановки казалось простой задачи)

Похожие вопросы

Обсуждают сегодня

Ajeeb aadmi hai, isko padhna nahi aata kya?
Jay Bansal
43
@LGCYMan @JustinKKW Q/A List 1. this part confuses me on #8: "From there, a bridge between erc20 LGXY and erc20 LGXY will be out once that swap is closed." does this mean ...
Sig | LGXY | BattleVerse L1 | BitWin
1
TBH... we can point fingers both ways, right? Not all but may times it can get very emotional and targeting. I have talked with Mike, and I understand where he is coming from ...
Carl Parker
12
I swear @MikeHerron looks at my calendar and jumps in when I am in meetings! LOL Anyways... we get some venting out of our systems today? Will restate again... we both have ...
Carl Parker
5
а зачем этот вопрос для удаления из чата?
Mёdkinson Medvezhkin
63
Mike Calling people here "stupid" and "sell your kda" what kind of manager is this??? If I'm his boss, he gets a letter of dismissal now, anyway after the speech of your "mark...
Spanz y
13
A couple of other tidbits just because I'm feeling saucy today. 1. If you already know about KDA and/or Kadena (which are different) why would I put paid support behind try...
Mike Herron
2
Only that screenshot was leaked. The question is how much information of this type has been released in that group?
Palmar 🎧 | Sound Element
12
It's the same people who keep importing their narrative into BCH spaces again and again. @BitcoinCashPodcast , @chrisgoodwin79 People that want to read toxic maxi spam can a...
2qx#72497; 🦇
9
My feelings on this: To @appmandolin point. You have to ask yourself, why was this channel made in the first place? The name "EOS Elites" itself insinuates there's a class o...
Kameron James | zeos.one
3
Карта сайта