On Mon, 15 Nov 2004 05:11:48 -0800 (PST), Tomas Fulajtar
<fu...@ya...> wrote:
> Hi all,
>
> i would like to ask you if could be possible to acces
> intermediate table column in many to many
> relationship.
>
> For example:
>
> CREATE TABLE person (
> id SERIAL,
> username VARCHAR(100) NOT NULL UNIQUE
> );
>
> CREATE TABLE role (
> id SERIAL,
> name VARCHAR(50) NOT NULL UNIQUE
> );
>
> CREATE TABLE assigned_roles (
> person INT NOT NULL,
> role INT NOT NULL,
> assigned_date DATE
> );
>
> I would like to access the assigned_date column. Does
> anybody have any idea? In the docs there is following
> solution, but without using any columns from
> intermediate table.
>
> class Person(SQLObject):
> username = StringCol(length=100, alternateID=True)
> roles = RelatedJoin('Role', joinColumn='person',
> otherColumn='role',
>
> intermediateTable='assigned_roles')
> class Role(SQLObject):
> name = StringCol(length=50, alternateID=True)
> roles = RelatedJoin('Person', joinColumn='role',
> otherColumn='person',
>
> intermediateTable='assigned_roles')
I think you can define class for assigned_roles, just like for any
other SQLObject class:
class AssignedRoles:
person = ForeignKey('Person')
role = ForeignKey('Role')
assignedDate = DateTimeCol()
--
Ksenia
|