Marcin Krol wrote: rsv = session.query(Reservation).filter(Reservation.id == > int(rid)).first() > > rhost = > session.query(Host).filter(Host.id.in_(rhostsel)).order_by(Host.ip).first() > > host = > session.query(Host).filter(Host.id.in_(hostsel)).order_by(Host.ip).first() >
these three queries may not return the same result each time, since you are calling first(). Subsequent results will be discarded, and if Host.ip contains repeats, you'll get non-deterministic results. > This lasts until the restart of the webserver, upon which the correct > value is read into session again. is there any caching in use ? global variables ? the Session itself should be closed out after each request (i.e. session.close()) so its not involved in the equation - data should not be carried over between requests unless you've specifically decided its safe to cache elsewhere. Sessions dont necessarily lose all their data "automatically" since strong references may remain between mutually-referencing objects (like in backrefs). > I have checked that on updating the object the correct value gets > written to the backend db. It's just subsequent queries to the current > session randomly return one of the former object attribute values. very easy to turn on SQL echoing, particularly DEBUG, and see exactly what queries are issued and what results they are returning. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
