Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Multi-table Models and Fixtures
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Greg Taylor  
View profile  
 More options Jun 1 2008, 11:19 pm
From: Greg Taylor <squishywaf...@gmail.com>
Date: Sun, 1 Jun 2008 20:19:46 -0700 (PDT)
Local: Sun, Jun 1 2008 11:19 pm
Subject: Multi-table Models and Fixtures
It seems like multi-table sub-classed models (not abstract) don't
honor the "pk" being specified in fixtures. For example, I have an
Event class that is sub-classed by a Race model. The Event class is in
an app called "calendar" and the Race model is in an app called
"regattas". I dumpdata regattas, reset both apps, and loaddata the
regattas fixture. It loads properly but all of the PKs are now
sequential, meaning a lot of other models are now pointing at the
wrong regatta entry. There were regattas with IDs 14, 16, and 18, but
are now 1, 2, and 3. I have confirmed that the fixture contains the
old 14, 16, and 18 primary keys.

The problem is the keys seem to be compacted rather than being loaded
from the fixture. The keys are not always sequential due to deletes.
So the problem doesn't exhibit itself until you delete, dumpdata, then
try to re-load.

Does anyone have any good way to get around this problem? It's
somewhat of a show-stopper for us.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Taylor  
View profile  
 More options Jun 2 2008, 11:05 am
From: Greg Taylor <squishywaf...@gmail.com>
Date: Mon, 2 Jun 2008 08:05:09 -0700 (PDT)
Local: Mon, Jun 2 2008 11:05 am
Subject: Re: Multi-table Models and Fixtures
I've been looking through the source to try to see if there is any
indicator as to whether this is the intended behavior. If nobody
speaks up today, I'll file a bug, as it would appear to be.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Taylor  
View profile  
 More options Jun 8 2008, 12:09 pm
From: Greg Taylor <squishywaf...@gmail.com>
Date: Sun, 8 Jun 2008 09:09:47 -0700 (PDT)
Local: Sun, Jun 8 2008 12:09 pm
Subject: Re: Multi-table Models and Fixtures
I've submitted a bug about this since I haven't been able to turn up
any kind of response. In the mean-time, I've had to rig something up
with generic relations to serve the same purpose. It's a really nasty
kludge, I think, which is a shame. I can't believe this hasn't cropped
up with anyone else yet, it seems like a really glaring problem,
especially for those who use fixtures.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Keith-Magee  
View profile  
 More options Jun 8 2008, 9:39 pm
From: "Russell Keith-Magee" <freakboy3...@gmail.com>
Date: Mon, 9 Jun 2008 09:39:58 +0800
Local: Sun, Jun 8 2008 9:39 pm
Subject: Re: Multi-table Models and Fixtures

On Mon, Jun 9, 2008 at 12:09 AM, Greg Taylor <squishywaf...@gmail.com> wrote:

> I've submitted a bug about this since I haven't been able to turn up
> any kind of response. In the mean-time, I've had to rig something up
> with generic relations to serve the same purpose. It's a really nasty
> kludge, I think, which is a shame. I can't believe this hasn't cropped
> up with anyone else yet, it seems like a really glaring problem,
> especially for those who use fixtures.

Hi Greg,

Apologies for not responding sooner, even if just to let you know that
you're not howling at the moon. I'm not ignoring you - I just don't
have anything to add at this point.

Yes, there is some work required on serialization to support some of
the additions to QS-RF. Inherited models are one problematic area;
models with non-primary OneToOneFields are another (although the
problems are probably related). As soon as I've finished this email,
I'm going to take a look at these problems and see what I can do about
a fix.

Yours,
Russ Magee %-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Taylor  
View profile  
 More options Jun 9 2008, 8:06 am
From: Greg Taylor <squishywaf...@gmail.com>
Date: Mon, 9 Jun 2008 05:06:19 -0700 (PDT)
Local: Mon, Jun 9 2008 8:06 am
Subject: Re: Multi-table Models and Fixtures
Much appreciated, Russ! I was not sure whether I was doing something
wrong or not, this is good to know this is being looked at. I tinkered
with a fix for a while but ultimately fell flat on my back for lack of
experience with Django internals. Let me know if I can assist with
testing or provide more details.

Thanks again,
Greg

On Jun 8, 9:39 pm, "Russell Keith-Magee" <freakboy3...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Keith-Magee  
View profile  
 More options Jun 9 2008, 8:12 am
From: "Russell Keith-Magee" <freakboy3...@gmail.com>
Date: Mon, 9 Jun 2008 20:12:20 +0800
Local: Mon, Jun 9 2008 8:12 am
Subject: Re: Multi-table Models and Fixtures

On Mon, Jun 9, 2008 at 8:06 PM, Greg Taylor <squishywaf...@gmail.com> wrote:

> Much appreciated, Russ! I was not sure whether I was doing something
> wrong or not, this is good to know this is being looked at. I tinkered
> with a fix for a while but ultimately fell flat on my back for lack of
> experience with Django internals. Let me know if I can assist with
> testing or provide more details.

I think I have it pretty much under control. I'm just finessing some
test cases at the moment. It turns out there are actually a couple of
related problems - too much data was being serialized, primary keys
were missing a few critical annotations, and the save process was a
little too enthusiastic about creating new parent instances. However,
I think I've got a solution now; a little more testing, and there
should be something in trunk. Watch this space. :-)

Yours,
Russ Magee %-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Taylor  
View profile  
 More options Jun 9 2008, 8:43 am
From: Greg Taylor <squishywaf...@gmail.com>
Date: Mon, 9 Jun 2008 05:43:12 -0700 (PDT)
Local: Mon, Jun 9 2008 8:43 am
Subject: Re: Multi-table Models and Fixtures
Excellent news, I appreciate it very much!

On Jun 9, 8:12 am, "Russell Keith-Magee" <freakboy3...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Keith-Magee  
View profile  
 More options Jun 9 2008, 10:06 am
From: "Russell Keith-Magee" <freakboy3...@gmail.com>
Date: Mon, 9 Jun 2008 22:06:40 +0800
Local: Mon, Jun 9 2008 10:06 am
Subject: Re: Multi-table Models and Fixtures
On Mon, Jun 9, 2008 at 8:12 PM, Russell Keith-Magee

OK; committed as [7600]. Let me know if you continue to have
difficulties with this.

Yours,
Russ Magee %-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Taylor  
View profile  
 More options Jun 9 2008, 10:09 am
From: Greg Taylor <squishywaf...@gmail.com>
Date: Mon, 9 Jun 2008 07:09:26 -0700 (PDT)
Local: Mon, Jun 9 2008 10:09 am
Subject: Re: Multi-table Models and Fixtures
Wonderful, I'll be able to test this pretty extensively tonight.

Since I don't think it's documented either way, is there a particular
procedure I should abide by when dumping/reloading fixtures for the
parent and child models? In my case, the parent is in one app, and the
child is another. Do I dumpdata for both of those apps and load them
in a certain order, or just dump for the child class that inherits
access to all of the fields and re-load that fixture?

Thanks again, this will get my project back on track!

On Jun 9, 10:06 am, "Russell Keith-Magee" <freakboy3...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Keith-Magee  
View profile  
 More options Jun 9 2008, 10:19 am
From: "Russell Keith-Magee" <freakboy3...@gmail.com>
Date: Mon, 9 Jun 2008 22:19:13 +0800
Local: Mon, Jun 9 2008 10:19 am
Subject: Re: Multi-table Models and Fixtures

On Mon, Jun 9, 2008 at 10:09 PM, Greg Taylor <squishywaf...@gmail.com> wrote:

> Wonderful, I'll be able to test this pretty extensively tonight.

> Since I don't think it's documented either way, is there a particular
> procedure I should abide by when dumping/reloading fixtures for the
> parent and child models? In my case, the parent is in one app, and the
> child is another. Do I dumpdata for both of those apps and load them
> in a certain order, or just dump for the child class that inherits
> access to all of the fields and re-load that fixture?

I've just added some docs about this [1]. You will need to dump both
parent class and child class. If they're in separate applications,
that means dumping both applications (or parts of both applications,
as appropriate).

When fixtures are reloaded, all the fixtures you load in a single
loaddata command are loaded inside a single transaction. Referential
integrity (when it's supported by your database) isn't checked until
the end of the transaction, so the order of creation internal to the
transaction doesn't matter. As a result, all the following:

loaddata all_data.json
loaddata parents.json children.json
loaddata children.json parents.json

will all be equivalent.

There is, of course, once caveat to this - if you're using MySQL with
InnoDB tables, all bets are off. InnoDB has referential integrity, but
it doesn't defer to end of transaction, so creation order becomes
important. This is a known bug, but one that is impossible to solve in
a generic fashion at our end - we need MySQL to fix their referential
integrity implementation. MyISAM tables aren't affected - they don't
have any referential integrity, so no checks are ever performed.

[1] http://www.djangoproject.com/documentation/serialization/#inherited-m...

Yours,
Russ Magee %-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Taylor  
View profile  
 More options Jun 9 2008, 10:22 am
From: Greg Taylor <squishywaf...@gmail.com>
Date: Mon, 9 Jun 2008 07:22:12 -0700 (PDT)
Local: Mon, Jun 9 2008 10:22 am
Subject: Re: Multi-table Models and Fixtures
That clears it up perfectly. This is great to have working, thanks
again!

Greg

On Jun 9, 10:19 am, "Russell Keith-Magee" <freakboy3...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »