[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-15 Thread Alexandre Conrad
Michael Bayer wrote: that doesnt sound right. taking out select_table, and doing: print Media .query .select_from (media_table .join (catalog_table ).join (catalog_channel_table )).filter(CatalogChannel.c.id_channel==playlist.id_channel).all() leads to the SQL:

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 10:44 AM, Alexandre Conrad wrote: Michael Bayer wrote: I came up with a very easy way to implement this which I'd like you to try out in rev 4060. So far I've tested with a basic joined table inheritance setup. All you do is place class-mapped attributes

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 10:44 AM, Alexandre Conrad wrote: model.Media.query.join([catalog, model .CatalogChannel .channel ]).filter (model.CatalogChannel.c.id_channel==c.playlist.id_channel).all() is CatalogChannel.channel a self referential relation to another Channel ? the classes you

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 12:04 PM, Michael Bayer wrote: On Jan 14, 2008, at 11:59 AM, Michael Bayer wrote: On Jan 14, 2008, at 10:44 AM, Alexandre Conrad wrote: model.Media.query.join([catalog, model .CatalogChannel .channel ]).filter

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Alexandre Conrad
Mike, Michael Bayer wrote: a certain id_channel. otherwise im still having trouble wrapping my head around what youre trying to do there. Enough guessing, here's the full test case with description of what I'm trying to do. :) Although, I wasn't able to make it run with sqlite, so it's

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 12:12 PM, Alexandre Conrad wrote: Mike, Michael Bayer wrote: a certain id_channel. otherwise im still having trouble wrapping my head around what youre trying to do there. Enough guessing, here's the full test case with description of what I'm trying to do. :)

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 11:59 AM, Michael Bayer wrote: On Jan 14, 2008, at 10:44 AM, Alexandre Conrad wrote: model.Media.query.join([catalog, model .CatalogChannel .channel ]).filter (model.CatalogChannel.c.id_channel==c.playlist.id_channel).all() like, are you sure you dont want to

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Alexandre Conrad
Alexandre Conrad wrote: under a foo table with MySQL. (another hidden bug, I'm getting a foo schema/db, not table. -- Alexandre CONRAD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 10:44 AM, Alexandre Conrad wrote: model.Media.query.join([catalog, model .CatalogChannel .channel ]).filter (model.CatalogChannel.c.id_channel==c.playlist.id_channel).all() like, are you sure you dont want to just say: model .Media .query .join ([catalog ]).filter

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Alexandre Conrad
Michael Bayer wrote: thats not hidden. SQLite cannot autoincrement primary key columns if the table contains a composite primary key which is the case here. Ah, yes. Plus, I don't need composite primary_key here, it's articact from an old many-to-many secondary table (which I usually set

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 12:12 PM, Alexandre Conrad wrote: Mike, Michael Bayer wrote: a certain id_channel. otherwise im still having trouble wrapping my head around what youre trying to do there. Enough guessing, here's the full test case with description of what I'm trying to do. :)

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Alexandre Conrad
Michael Bayer wrote: your best bet with this mapping right now is: print Media .query .select_from (media_table .join (catalog_table ).join (catalog_channel_table )).filter(CatalogChannel.c.id_channel==playlist.id_channel).all() which is really how select_from() was

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 12:12 PM, Alexandre Conrad wrote: Mike, Michael Bayer wrote: a certain id_channel. otherwise im still having trouble wrapping my head around what youre trying to do there. Enough guessing, here's the full test case with description of what I'm trying to do. :)

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Alexandre Conrad
Mike, My day is over, I'm leaving the office. I'll read your replies tomorrow. Thanks for taking some time one that. Regards, -- Alexandre CONRAD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-14 Thread Michael Bayer
On Jan 14, 2008, at 12:44 PM, Alexandre Conrad wrote: Michael Bayer wrote: your best bet with this mapping right now is: print Media .query .select_from (media_table .join (catalog_table ).join (catalog_channel_table

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-13 Thread Alexandre Conrad
Michael Bayer wrote: I dont see where the type element youre mentioning is present in this query. if Media points to Catalog, thats the end of the story - what is telling it about a CatalogChannel ? Okay, okay Mike and Svilen. Of course ! I was thinking we could figure out that if a

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-13 Thread Michael Bayer
On Jan 13, 2008, at 1:02 PM, Alexandre Conrad wrote: Okay, okay Mike and Svilen. Of course ! I was thinking we could figure out that if a media being attached to a Catalog of type channel, thus a CatalogChannel polymorphically speaking, would figure out that Media.query.join([catalog,

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-13 Thread Alexandre Conrad
Michael Bayer wrote: On Jan 13, 2008, at 1:02 PM, Alexandre Conrad wrote: Anyway, my inital issue according to the subject's title, is that: .filter(Catalog.c.id==CatalogChannel.c.id) generates the SQL query catalogs.id = catalogs.id rather than the expected catalogs.id =

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-13 Thread Michael Bayer
On Jan 13, 2008, at 2:33 PM, Alexandre Conrad wrote: Ahh, good to hear. It would feel more natural to me. We'd expect that CatalogChannel's table is catalog_channel_table, specially when we earlier set mapper(CatalogChannel, catalog_channel_table). Plus, using tables makes me have extra

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Alexandre Conrad
svilen wrote: On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote: Channel - Playlist - Media Channel - CatalogChannel(Catalog) - Media (Media has a fk to Catalog, not CatalogChannel) The only element I have, is playlist (instance of Playlist). At this point, I need to find out the

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread svilen
On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote: svilen wrote: Here is the syntax followed by the generated query: query.filter(Catalog.c.id==CatalogChannel.c.id) WHERE catalogs.id = catalogs.id why u need such a query? that's exactly what (inheritance) join does, and

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread svilen
On Friday 11 January 2008 13:58:34 Alexandre Conrad wrote: Hi, playing with inheritance, I figured out that an inherited mapped class passed to filter doesn't point to the correct table. I have 2 classes, Catalog and CatalogChannel(Catalog). Here is the syntax followed by the generated

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread svilen
On Friday 11 January 2008 17:03:06 Alexandre Conrad wrote: svilen wrote: On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote: Channel - Playlist - Media Channel - CatalogChannel(Catalog) - Media (Media has a fk to Catalog, not CatalogChannel) The only element I have, is playlist

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Michael Bayer
On Jan 11, 2008, at 10:03 AM, Alexandre Conrad wrote: svilen wrote: On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote: Channel - Playlist - Media Channel - CatalogChannel(Catalog) - Media (Media has a fk to Catalog, not CatalogChannel) The only element I have, is playlist

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Alexandre Conrad
svilen wrote: Here is the syntax followed by the generated query: query.filter(Catalog.c.id==CatalogChannel.c.id) WHERE catalogs.id = catalogs.id why u need such a query? that's exactly what (inheritance) join does, and automaticaly - just query( CatalogChannel).all() would give u

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-11 Thread Alexandre da Silva
I think I understand what you trying to do in fact polymorphic objects are load correctly in my test, I think it is an approach to your case. follow the code I used before to ask about polymorphic inheritance, note to the Catalog class, this class have a resource list (catalog_id on Resource),