[TIP] I need a DataSet fixture that points into its own table
phlip2005 at gmail.com
Mon Dec 27 14:50:36 PST 2010
> TreeData.leaf_one.owner = TreeData.branch
> TreeData.leaf_two.owner = TreeData.branch
Thanks, I thought I tried that.
> Mark S.
And, just to provide some closure, I have since replaced fixture with
a hand-made SQL (another incarnation of my "FactorySquirrel"
sketches!), that I hope to write-up soon.
It is 100 times faster, literally, because it does not fully rez
Django models and call .save() on them. It just pushes everyone into
the DB using INSERT.
I declare the fixtures like this:
Those are simply five database fields in a row - id, name, type,
owner_id, and payload.
The h() one-way encrypts a string as a short integer. (I tried to use
hash(), but MySQL kacked on the results. Don't know why; yes I tried
shifting out any overflow.)
That way if we see the h('species_branch'), first, we calculate its id
and INSERT it, and if a leaf needed a owner_id of h('species_branch')
first, we could have calculated and INSERTed that, too.
This gives me, without JSON, as close as I can get to how Ruby on
Rails does it. It inserts raw SQL, very rapidly, without wasting time
creating Django model objects. And it can links IDs without seeing
their records first, by hashing their names.
More information about the testing-in-python