dan -
this is a very serious issue ! the fix for your test is pretty easy,
when the lazy load operation occurs, it has to make sure it sets up
that "hasparent" relationship properly on the newly loaded objects.
but im still fixing it for eager loading, which currently bypasses
the attribute manager (that has to change).
i am extremely glad you found this bug before I released. because
look at the symptom:
m = mapper(User, users, properties={
'addresses':relation(Address, cascade="all,delete-
orphan", lazy=False)
})
mapper(Address, addresses)
s = create_session()
q = s.query(m)
user = q.get(7)
user.addresses[0].email_address='foo'
s.flush()
because of our enhancement to the unitofwork to double-check for
orphans, this flush sees the "Address" object as an orphan and
deletes it !!!
On Sep 1, 2006, at 10:23 AM, dmiller wrote:
> Let me try that again, with the attachment this time...
> <instrumentedattributetest.py>
>
> On Sep 1, 2006, at 10:21 AM, dmiller wrote:
>
>>>
>>> i think you understand this already; the way hasparent works is:
>>>
>>> if a class "A" has a property "bs", managed by
>>> InstrumentedAttribute "Bs" that points to instances of class "B",
>>> then
>>> "B" is an orphan if its _state does not contain a record
>>> "('hasparent',id(Bs))".
>>>
>>
>> Right, that's what I thought should happen. Now continue your example
>> so C has a property "b" managed by an InstrumentedAttribte "CB" that
>> points to an instance of class B. In my case the instance of class
>> "B" is getting a "('hasparent',id(CB))" record in its _state.
>>
>> Ahh, it looks like the same thing is happening in your test program,
>> so that's not causing my problem (and I guess it's not a bug either).
>> Why does that happen though? Here's another example:
>>
>> For reference, here's a snippet of the output of your test program:
>>
>> Blog.posts 6092976
>> Post.blog 6071408
>> ...
>> Blog: {('hasparent', 6071408): True, 'modified': True}
>> Post {('hasparent', 6206960): True, ('hasparent', 6092976): True,
>> 'modified': True}
>>
>> Why does b._state have a 'hasparent' record for p1.blog? That would
>> imply that "p1.blog" is the parent of "b", which doesn't seem logical
>> to me. This is exactly what was happening in my program (and I
>> thought it was a bug).
>>
>> However, this does give me a better understanding of the
>> InstrumentedAttribute parent tracking mechanism though, so thanks for
>> that. It allowed me to reproduce the scenario that is happening
>> within my program, and now I have a test that fails (see attached).
>>
>> ~ Daniel
>>
>>
>>
>> ---------------------------------------------------------------------
>> ----
>> Using Tomcat but need to do more? Need to support web services,
>> security?
>> Get stuff done quickly with pre-integrated technology to make your
>> job easier
>> Download IBM WebSphere Application Server v.1.0.1 based on Apache
>> Geronimo
>> http://sel.as-us.falkag.net/sel?
>> cmd=lnk&kid=120709&bid=263057&dat=121642
>> _______________________________________________
>> Sqlalchemy-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
>
> ----------------------------------------------------------------------
> ---
> Using Tomcat but need to do more? Need to support web services,
> security?
> Get stuff done quickly with pre-integrated technology to make your
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> http://sel.as-us.falkag.net/sel?
> cmd=lnk&kid=120709&bid=263057&dat=121642______________________________
> _________________
> Sqlalchemy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users