Hi, all. 

I'm trying to write a python library around the f-spot database. 
I used SQLO for a couple of projects so, I decided to use it here too. 
But f-spot database schema is not really standard so I need to use 
its intermediate table in a many to many. 

Here is the doc I used: 
http://www.sqlobject.org/FAQ.html#how-can-i-define-my-own-intermediate-table-in-my-many-to-many-relationship

And here is the result code.

    
class Photo(SQLObject):
    class sqlmeta:
        table = 'photos'
    time = IntCol()
    uri  = UnicodeCol()
    description = UnicodeCol()
    roll_id = IntCol()
    default_version_id  = IntCol()
    rating = IntCol()
    tags = RelatedJoin('Tag')
    tags = SQLRelatedJoin('Tag',intermediateTable='photo_tags')


class Tag(SQLObject):
    class sqlmeta:
        table = 'tags'
    name = UnicodeCol()
    category_id = IntCol()
    is_category = BoolCol()
    sort_priority = IntCol()
    icon = StringCol()
    photos = SQLRelatedJoin('Photo',intermediateTable='photo_tags')
        

class PhotosTags(SQLObject):
    class sqlmeta:
        table = 'photo_tags'
    photo = ForeignKey('Photo')
    tag = ForeignKey('Tag')



As you can see the photo_tags is the intermediate table (which links
photos to tags). That's look fine except that when I try to find tags 
for a given photo, I get something like this: 


(Pdb) print Photo.select()[2500].tags
SELECT tags.id, tags.name, tags.category_id, tags.is_category, 
tags.sort_priority, tags.icon FROM photos, photo_tags, tags WHERE ((tags.id = 
photo_tags.tags_id) AND ((photo_tags.photos_id = photos.id) AND (photos.id = 
5427)))


Ok, but the right column in the intermediate table is this : 
TABLE photo_tags ( photo_id      INTEGER, tag_id        INTEGER  );

As you can see the columns are photo_id and tag_id .. but SQLO is looking for 
photos_id and tags_id (look the s at the end)..


So my question is : The FAQ explain how to name and populate the intermediate 
table, but how can I set the column name 
for this table. 




Thanks for any help. 


-- 


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to