On Feb 27, 2011, at 3:28 AM, Chris Withers wrote:
> On 27/02/2011 06:34, Michael Bayer wrote:
>>
>>> More interestingly, why does the use of sessionmaker versus the use of the
>>> standard Session class make a difference?
>>
>> the unit of work issues INSERTS in order for a single kind of entity. It
>> doesn't do that across all entities since the dependency order between
>> entities takes precedence. Such as here if you did in fact set up
>> Parent.children for one or more objects, the UOW sorts entities in order of
>> dependency. Its new in 0.6 that Parent/Child are not sorted by
>> dependency if they have no relationship to each other, but if you had a
>> second Parent/Child which did have a relationship in the flush, then all the
>> Parents would be first and all the Childs second (since common entities are
>> batched together unless there are inter-row dependencies). This all has to
>> do with the flush process being as fast, batched, and memory-efficient as
>> possible.
>
> Okay, but why does sessionmaker versus Session make a difference here?
that is python set/dictionary behavior changing its ordering based on random
artifacts of the program.
I'm experimenting with a patch that will maintain the parent/child dependency
between naturally dependent objects even if no relationship has been
established between them. It causes all Parents to go in before all Child,
just by the fact that the relationship exists. This aspect of the behavior
also happened in 0.5 which had a way more bloated system of figuring this stuff
out.
--- a/lib/sqlalchemy/orm/dependency.py Fri Feb 25 13:20:43 2011 -0500
+++ b/lib/sqlalchemy/orm/dependency.py Sun Feb 27 10:23:00 2011 -0500
@@ -242,7 +242,7 @@
if history and not history.empty():
return True
else:
- return False
+ return self.mapper in uowcommit.mappers
def _verify_canload(self, state):
if state is not None and \
>
> Chris
>
> --
> Simplistix - Content Management, Batch Processing & Python Consulting
> - http://www.simplistix.co.uk
>
> --
> 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.
>
--
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.