I can't make a guess without a script to reproduce it I'm afraid.

Sorry,

Simon

On Mon, Oct 14, 2019 at 8:35 AM natsjoo sodillepa <snats...@gmail.com> wrote:
>
> Ok,
>
> I have managed to get rid of the problem, but I'm don't like what is 
> happening.
> Solution: remove a secondary relation from the model:
>
> model = relationship("Model", secondary='item_group', uselist=False)
>
>
> After this, the following code does do a proper delete of the items:
>
> for it in self.session.query(ItemMeta).filter_by(item_group=item_group).all():
>     if type(it) == ItemMeta:
>         item_group.items.remove(it)
>         self.session.delete(it)
> self.session.commit()
>
>
> However, things are still not ideal. The following should work but doesn't:
>
> for item in item_group.items:
>    self.session.delete(item)
>
> Then only half of the item get deleted, which is a bit weird.
>
> Anybody any thoughts on this? Why does a secondary relation of this kind of 
> effect on a delete?
>
> Kinde regards,
> Nacho
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> ---
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/073b7947-ed51-4b63-bfdb-a5499128c06c%40googlegroups.com.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexf05rvzhR068JJ8SYP%2BxgZmgBb-bN2V-LDSZQ8AriGU9g%40mail.gmail.com.

Reply via email to