Account Options

  1. Sign in
Google Groups Home
« Groups Home
Ticket #8161 - Please help me fix this.
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
  5 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
 
Madhusudan C.S  
View profile  
 More options Mar 11 2009, 11:31 am
From: "Madhusudan C.S" <madhusuda...@gmail.com>
Date: Wed, 11 Mar 2009 21:01:32 +0530
Local: Wed, Mar 11 2009 11:31 am
Subject: Ticket #8161 - Please help me fix this.

Hi all,
     I wanted to fix this bug. I just went through the code to see what was
happening. For the same sample code given in the ticket, these were my
findings:

The schema generated looks like this and there is no issue with it:
CREATE TABLE "testapp_childmodel" (
    "parentmodel_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES
"testapp_parentmodel" ("id"),
    "text" text NOT NULL
);
CREATE TABLE "testapp_parentmodel" (
    "id" integer NOT NULL PRIMARY KEY,
    "slug" varchar(50) NOT NULL
);
CREATE TABLE "testapp_parentmodel_links" (
    "id" integer NOT NULL PRIMARY KEY,
    "from_parentmodel_id" integer NOT NULL REFERENCES "testapp_parentmodel"
("id"),
    "to_parentmodel_id" integer NOT NULL REFERENCES "testapp_parentmodel"
("id"),
    UNIQUE ("from_parentmodel_id", "to_parentmodel_id")
);

CREATE INDEX "testapp_parentmodel_slug" ON "testapp_parentmodel" ("slug");

I inserted test1, test2 and test3(all names being values of slug field) to
ParentModel and linked test1 and test3 to test2 through links field. There
seems to be no issues. Then I inserted testc1, testc2 and testc3 to
ChildModel and linked testc2 and testc3 to testc1 through inherited links
field. Now I can see only to links, i.e
I get these results in the interactive interpreter:

>>> from dummy.testapp.models import ParentModel, ChildModel
>>> c1 = ChildModel.objects.get(slug='testc1')
>>> c2 = ChildModel.objects.get(slug='testc2')
>>> c3 = ChildModel.objects.get(slug='testc3')
>>> c1.links.all()
[]
>>> c2.links.all()

[<ParentModel: testc1>]
>>> c3.links.all()

[<ParentModel: testc1>]

This means only to links are being queried and not from links for the
inherited model. I just saw how the queries are working and these are the
queries constructed for c1, c2 and c3 respectively.

SELECT "testapp_parentmodel"."id", "testapp_parentmodel"."slug" FROM
"testapp_parentmodel" INNER JOIN "testapp_parentmodel_links" ON
("testapp_parentmodel"."id" =
"testapp_parentmodel_links"."to_parentmodel_id") WHERE
"testapp_parentmodel_links"."from_parentmodel_id" = 4  LIMIT 21

SELECT "testapp_parentmodel"."id", "testapp_parentmodel"."slug" FROM
"testapp_parentmodel" INNER JOIN "testapp_parentmodel_links" ON
("testapp_parentmodel"."id" =
"testapp_parentmodel_links"."to_parentmodel_id") WHERE
"testapp_parentmodel_links"."from_parentmodel_id" = 5  LIMIT 21

SELECT "testapp_parentmodel"."id", "testapp_parentmodel"."slug" FROM
"testapp_parentmodel" INNER JOIN "testapp_parentmodel_links" ON
("testapp_parentmodel"."id" =
"testapp_parentmodel_links"."to_parentmodel_id") WHERE
"testapp_parentmodel_links"."from_parentmodel_id" = 6  LIMIT 21

From what I see the queries must be actually UNION of two queries which
fetch data both from, "from" and "to" fields in the
"testapp_parentmodel_links" table.It should look some thing like this, from
what I have understood:

SELECT "testapp_parentmodel"."id", "testapp_parentmodel"."slug" FROM
"testapp_parentmodel" INNER JOIN "testapp_parentmodel_links" ON
("testapp_parentmodel"."id" =
"testapp_parentmodel_links"."to_parentmodel_id") WHERE
"testapp_parentmodel_links"."from_parentmodel_id" = 4  LIMIT 21
UNION
SELECT "testapp_parentmodel"."id", "testapp_parentmodel"."slug" FROM
"testapp_parentmodel" INNER JOIN "testapp_parentmodel_links" ON
("testapp_parentmodel"."id" =
"testapp_parentmodel_links"."from_parentmodel_id") WHERE
"testapp_parentmodel_links"."to_parentmodel_id" = 4  LIMIT 21

Is this an elegant approach? If so can some one help me implement this? I
went through the code of QuerySet, Manager classes and other parts of
django.db.models. How to go about from here? I am very keen on fixing this
issue. Kindly help me.

--
Thanks and regards,
 Madhusudan.C.S

Blogs at: www.madhusudancs.info
Official Email ID: madhusu...@madhusudancs.info

P.S: I am really sorry if the text is not wrapped. I am still not
understanding how wrapping works here. Will correct it from next mail. Hope
Auto text wrapping works.


 
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.
Alex Gaynor  
View profile  
 More options Mar 11 2009, 11:41 am
From: Alex Gaynor <alex.gay...@gmail.com>
Date: Wed, 11 Mar 2009 10:41:02 -0500
Local: Wed, Mar 11 2009 11:41 am
Subject: Re: Ticket #8161 - Please help me fix this.

On Wed, Mar 11, 2009 at 10:31 AM, Madhusudan C.S <madhusuda...@gmail.com>wrote:

This looks like it may just be a symptom of
http://code.djangoproject.com/ticket/10237 if I'm reading htis correctly.

Alex

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


 
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.
Madhusudan C.S  
View profile  
 More options Mar 11 2009, 3:45 pm
From: "Madhusudan C.S" <madhusuda...@gmail.com>
Date: Thu, 12 Mar 2009 01:15:28 +0530
Local: Wed, Mar 11 2009 3:45 pm
Subject: Re: Ticket #8161 - Please help me fix this.

Hi Alex,
    First of all thanks a lot for the reply.

doesn't seem to solve the problem at least for the data set I created as
above. So problem exists some where else too. Any pointers to where it might
be? (The query i.e being generated essentially remains the same even after
applying the supplied patch). But manager.symmetrical which used to return
False now correctly returns True.

--
Thanks and regards,
 Madhusudan.C.S

Blogs at: www.madhusudancs.info
Official Email ID: madhusu...@madhusudancs.info


 
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.
Madhusudan C.S  
View profile  
 More options Mar 11 2009, 6:25 pm
From: "Madhusudan C.S" <madhusuda...@gmail.com>
Date: Thu, 12 Mar 2009 03:55:03 +0530
Local: Wed, Mar 11 2009 6:25 pm
Subject: Re: Ticket #8161 - Please help me fix this.

Hi Alex,
    Sorry for wasting your time :(
On Thu, Mar 12, 2009 at 1:15 AM, Madhusudan C.S <madhusuda...@gmail.com>wrote:

Sorry for sending this mail without testing. Did not notice that to test the
patch the new data must be saved into the database or the old data updated.
Was just trying with the existing data after applying the patch. The patch
submitted in the ticket #10237 works fine for me.
Thanks to justinlilly for the patch and thanks Alex for the help. Sorry for
bothering you a lot.
**

--
Thanks and regards,
 Madhusudan.C.S

Blogs at: www.madhusudancs.info
Official Email ID: madhusu...@madhusudancs.info


 
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.
Alex Gaynor  
View profile  
 More options Mar 11 2009, 6:37 pm
From: Alex Gaynor <alex.gay...@gmail.com>
Date: Wed, 11 Mar 2009 17:37:10 -0500
Local: Wed, Mar 11 2009 6:37 pm
Subject: Re: Ticket #8161 - Please help me fix this.

On Wed, Mar 11, 2009 at 5:25 PM, Madhusudan C.S <madhusuda...@gmail.com>wrote:

This was anything but time wasted, we now know something we didn't before.

Alex

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


 
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 »