Re: [sqlalchemy] Setting the FK not performed when relationship is declared

2020-12-10 Thread Nikola Radovanovic
Yes, my bad; it should state: # at this moment, child.parent_id is None. What is strange, when added single_parent=True to the relationship - it then worked as I would expected. I guess its some of my misunderstanding of how relationship works. In case needed, I will set

Re: [sqlalchemy] Setting the FK not performed when relationship is declared

2020-12-10 Thread Simon King
I can't see anything obviously wrong with what you've written (you said "child.id is None", but I assume you meant child.parent_id). Can you provide a runnable example? Simon On Thu, Dec 10, 2020 at 8:27 AM Nikola Radovanovic wrote: > > Hi, > I have a FK in child pointing to parent table. Also,

[sqlalchemy] Setting the FK not performed when relationship is declared

2020-12-10 Thread Nikola Radovanovic
Hi, I have a FK in child pointing to parent table. Also, there is a relationship towards parent from children. I would like to create children and set FK to parent explicitly, without previously loading the parent object. After commit, FK of parent in child table is None. In case I remove