On Wed, Jan 2, 2019 at 2:00 PM Daniel Leon <[email protected]> wrote: > > Sometimes when I do session.refresh(self) a foreign field > self.ProductionOrder is sometimes a different object than before.
that can happen if you have changed foreign key column values, sure > I have non-database fields on ProductionOrder that are lost. that seems like not a great idea if you are going to be calling refresh(), which itself is not a method you normally need to use, but short of a test case that shows it doing the wrong thing, it is likely doing what you are asking it to do. > I have expire_on_commit=False so I expect an object corresponding to a > database row to persist. sure, but refresh() is an explicit request to blow an object away if that's what the state of the DB is. > Debugging, I see that this object replacement occurs after self.refresh(). I > haven't determined the conditions under which it occurs. Any thoughts? it's likely expiring a lazy-loaded attribute which re-loads the next time you access it. refresh() is not a method that is normally needed so I'd ask more specifically what it is you are trying to do. > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
