It cost me some time to analyse this problem. ;) The problem in the pseudo-code below is that 'obj' lose the reference to its foreign-key object (set with relationship()). The foreign key member itself is still correct set with a numeric value.
I understand that this can happen because of the reference cycle counting stuff in the background of SQLA. But how can I prevent this? obj = GetObjFromDb() make_transient(obj) obj._pk = None # This can return 'None' in some cases obj.GetForeignKeyObject() I found this out because of some debug messages put out with print(). When I call print(obj) (this implicit a GetForeignKeyObject()) BEFORE make_transient() it doesn't lose the reference to its foreign-key-object. :D -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
