On 26 Ott, 15:29, Mike Conley <[email protected]> wrote:

> > So, in Python a non-automatic shallow copy would be:
>
> > A = Some_class()
> > A.refs = [B, C]
> > Acopy = Some_class()
> > Acopy.refs = A.refs
>
> > My problem is that if A.refs has to be lazy loaded, when I try to copy
> > it over to Acopy, it triggers the query, and I'd like to avoid that,
> > while still copying the fact that Acopy.refs should be the same as
> > A.refs.
>
> So, let's understand the underlying data model.
>
> We say, A is a parent object related to B and C children.
> (1) If this is a one-to-many relationship, then B and C will contain foreign
> keys pointing at A. Copying of A to Acopy cannot have references point at
> [B, C] because the children cannot point at two parents at the same time;
> there is only one foreign key column.
> (2) If this is a many-to-many relationship, then there will be another table
> between A and [B,C] managing the many-to-many connection and something needs
> to be done during the copy to preserve the relationships.
>
> Which do we have here?


Ehr.. Both :) I'm looking for a generic way to build a shallow copy,
so the relations could be of any type.
Anyway, now that you point it out I'm thinking that maybe there's no
way to just copy the informations that would allow SQLA to perform the
lazy loading from the new instance, since this instance would have no
ID at all, and SQLA couldn't possibly match it with related data..
Maybe that could have worked with Hibernate, since it uses Proxy
objects to implement lazy loading..

Many thanks for your assistance! :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to