On 6/25/06, Jorge Vargas <[EMAIL PROTECTED]> wrote:
> the first one is a common problem with SQLObject and Many-to-Many
> relationships

> http://trac.turbogears.org/turbogears/wiki/JoinaTableWithItself

I have a question:
How can I get the Region's parent Region?

class Region(SQLObject):
    name =  StringCol(alternateID=True)
    borders = 
RelatedJoin("Region",joinColumn='borders_id',otherColumn='parent_id')
    parent_region =
RelatedJoin("Region",joinColumn='parent_id',otherColumn='borders_id')

SO will create table as,

CREATE TABLE region_region (
parent_id INT NOT NULL,
borders_id INT NOT NULL
);

Then region1.borders will get region1's parent region
region1.parent_region will get region1's borders


class Region(SQLObject):
    name =  StringCol(alternateID=True)
    parent_region =
RelatedJoin("Region",joinColumn='borders_id',otherColumn='parent_id')
    borders = 
RelatedJoin("Region",joinColumn='parent_id',otherColumn='borders_id')

SO will create table as;

CREATE TABLE region_region (
borders_id INT NOT NULL,
parent_id INT NOT NULL
);

Then region1.borders stilll get region1's parent region
region1.parent_region stilll get region1's borders

I'm confused, how can I get the region's parents region?


-- 
I'm the one, powered by nEO

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to