On Tue, Jul 20, 2021, at 10:00 AM, Evgenii wrote:
> As it was mentioned before, I create repeated elements in relationship
> deliberately.
Assuming this implies the table can have no candidate key, this is an
antipattern in SQL and there are lots of answers/articles/etc on the web why
all re
As it was mentioned before, I create repeated elements in relationship
deliberately. Moreover, alchemy allows me to do that, but it fails during
deleting instances and modifying relationships.
Unfortunately, this is not that case, where I can start all over again. All
examples are maximally simp
if you are mapping ORM classes to the same table that is also used as the
"secondary" table in a relationship() that can lead to the ORM inserting more
than one row for that table. based on the name "foo_bar" I would imagine
something like this might be going on.
>
> Pls tell how to dele
Mike, thank you for the answer.
But I have another problem with deleting the instance.
Even though all instances belong to the same session (it is possible to
push foo instance):
with Session() as session:
b1 = session.query(BarTable).get(1)
b2 = session.query(BarTable).get(1)
foo =
This is all expected behavior, the main reason you're having problems is that
you are using multiple sessions and mixing their results together.If you
need to do this, there are few approaches, the most basic being to use the
merge() method:
https://docs.sqlalchemy.org/en/14/orm/session_api