On Friday, February 26, 2016 at 4:54:01 AM UTC-5, Simon King wrote:
>
>
> I'm not aware of any way to do this.
>
>
I'm not either, and I'm scared of the SQL that would be generated and the
wire traffic/memory if there were. That would be subselects within
subqueryloads within... this also seems a bit more about "updates to
associations" vs "association_proxy".
Just to step back for a second, calling `update()` on the relation would
require every object to be loaded from the database and into the identity
map. This is for 2 reasons: 1) the ORM works on objects, not the db
directly; 2) sqlalchemy would need to keep both objects in the database
and in-memory in sync (what if the 10% of the objects are loaded from
memory and the rest are in the DB?). Think of how that feature would work
on an object where a relation has 1MM rows in the association - the
computer could grind to a halt.
For this general task, I `flush` the session, use the `update` command on
the target class -- filtering the WHERE based on the parent object and
join conditions -- then I `expire_all` (because that update may have
affected in-memory object relations). There is a small hit on reloading
all the data, but I've found the `update` to run considerably faster and
make it worth-it.
--
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.