Hi,

I've attached a test script as I'm confused with what I'm trying to do.

I have the following scenario:

- A Channel object is TV channel:

class Channel:
     pass

- A Playlist object is a piece of a channel's TV program.

class Playlist:
     pass

- A Playlist can be declined as different Playlist types, (joined table 
inheritance). Thus, a PlaylistChannel object is a Playlist of type 
'channel':

class PlaylistChannel(Playlist):
     # type = "channel"
     pass

- A Channel object can only have (none or more) PlaylistChannel objects, 
available via it's "playlists" attribute:

chan = session.query(Channel).get(1)
chan.playlists # returns a list of PlaylistChannel objects.

- A Channel has an "active" attribute which points to one of the 
playlist (PlaylistChannel) of the channel.

chan.active # returns one of the playlist or None (scalar).




Channel.playlists <- (one-to-many) -> PlaylistChannel (list)
Channel.active <- (one-to-one) -> PlaylistChannel (scalar)

But SQLAlchemy seems lost because multiple heritance and foreign_keys 
are defined. It complains about:

"""
sqlalchemy.exceptions.ArgumentError: Error determining primary and/or 
secondary join for relationship 'Channel.active (PlaylistChannel)'. If 
the underlying error cannot be corrected, you should specify the 
'primaryjoin' (and 'secondaryjoin', if there is an association table 
present) keyword arguments to the relation() function (or for backrefs, 
by specifying the backref using the backref() function with keyword 
arguments) to explicitly specify the join conditions. Nested error is 
"Can't determine join between 'channels' and 'Join object on playlists 
playlist_channels'; tables have more than one foreign key constraint 
relationship between them. Please specify the 'onclause' of this join 
explicitly."
"""

And I just can't figure how which alchemy will make my scenario work 
correctly. I've tried playing with primaryjoin/secondaryjoin, but I just 
can't figure it out.

Please see the attached test case for more details. Thanks for your help.

Regards,
-- 
Alex

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Attachment: sqlalchemy_test.py
Description: application/python

Reply via email to