On Jun 4, 2013, at 11:15 AM, Michael Bayer <mike...@zzzcomputing.com> wrote:
> There seems to be some unfortunate effect going on, as the issue of backrefs > loading collections like this was long ago resolved to defer that activity, > but it appears that when uselist=False is present, this logic no longer takes > place. Ticket http://www.sqlalchemy.org/trac/ticket/2741 has been added to > look into this as this should not be happening. > OK I've looked into it, and it actually should be happening, because the difference between uselist=True and uselist=False is that when setting a uselist=False, the *old* value must be removed, so we have to load the old value in order to reflect that in the history. So when we say: plant.taxon = taxon_new SQLAlchemy must load "taxon.plant" on "taxon_new" to get the previous "plant" value that's present, if any, so that it can be de-associated with taxon_new as taxon.plant is uselist=False. This can't be determined with "taxon_new" alone - the database must be scanned for taxon_new's identity in the "plant" table. So by default this will also autoflush, so here you just want to temporarily disable autoflush. -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.