On Sat, Sep 10, 2011 at 8:19 AM, Anssi Kääriäinen
<[email protected]>wrote:

>
>
> On Sep 10, 1:55 pm, "Jonas H." <[email protected]> wrote:
> > I started hacking the loaddata command to make use of the shiny new
> > `bulk_create` code -- however, it seems that fixture loading (at least
> > in its current incarnation) is incompatible to bulk inserts, for this
> > reasons:
> >
> > 1. It's possible to have model objects overridden by fixtures.
> >     e.g. in modeltests/fixtures/fixtures/fixture1.json, there's a
> >     `fixtures.article` with pk=3, and in fixture2.json there's another
> >     pk=3 article which overrides that from fixture1.
> >
> >     Of course this is not compatible with forced inserts.
> >
> > 2. pre_save/post_save signals are not sent.
> >     It seems like it's not documented anywhere that signals are sent
> >     during fixture loading but I think that for backwards compatibility
> >     reasons this behaviour should not be changed.
> >
> > Any ideas on these issues?
>
> Why the signals aren't sent in bulk_insert, is it because PK is not
> necessarily  available for post_save signal? Otherwise one could send
> all pre_save signals in one batch before insert and for post_save just
> after. Cascading deletes do something like that IIRC. If this is
> impossible to do in bulk_insert, the signal sending could still be
> done manually in fixture loading. PK should be available there
> directly from the fixtures, right?
>
> For the overridden pk problem you could do batches of say 100 inserts
> at a time, first do "select pk from tbl where pk in (list of pks in
> batch)", then use update for the returned pks and insert the rest.
>
>  - Anssi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" 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/django-developers?hl=en.
>
>
I looked into using bulk_create for fixtures back at DjangoCon.eu, basically
it's a mess because fixtures are not necessarily creating data, they can
also be overwriting existing ones.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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/django-developers?hl=en.

Reply via email to