Re: [sqlalchemy] Polymorphic on another table?

2013-11-27 Thread Michael Bayer
On Nov 27, 2013, at 1:23 AM, 史永宏 shooting...@gmail.com wrote: Hi, Is there a solution for this issue today? Now I have a single table Inheritance in table A, however, the type information is stored in another table B linked from A with foreign key... Now if I want to get polymorphic

Re: [sqlalchemy] Polymorphic on another table?

2013-11-27 Thread 史永宏
This is super! Thanks Michael On Wednesday, November 27, 2013 7:49:23 AM UTC-8, Michael Bayer wrote: On Nov 27, 2013, at 1:23 AM, 史永宏 shoot...@gmail.com javascript: wrote: Hi, Is there a solution for this issue today? Now I have a single table Inheritance in table A, however, the type

Re: [sqlalchemy] Polymorphic on another table?

2013-11-26 Thread 史永宏
Hi, Is there a solution for this issue today? Now I have a single table Inheritance in table A, however, the type information is stored in another table B linked from A with foreign key... Now if I want to get polymorphic result when querying A, I got error ask me to either use polymorphic or

Re: [sqlalchemy] Polymorphic on another table?

2010-05-20 Thread Richard Kuesters
Hi Timmy and Michael, I was wandering here about the same problem. I have a table that defines keys and value type (ie: key 'username', type 'unicode max 60' - that it is a constant). Then, I have the values table, which is polymorphic on value type and also has a fk to keys table. I think it is

[sqlalchemy] Polymorphic on another table?

2010-05-05 Thread Timmy Chan
i have 4 tables, a, b, c, d. a has one-to-many relation with b, b with one-to-one relationship with c, c is a polymorphic on a.type, with d being one of the polymorphic types. is there a way to implement this? details: this is what im trying to do in sqlalchemy: a = Table('a', metadata,

Re: [sqlalchemy] Polymorphic on another table?

2010-05-05 Thread Michael Bayer
On May 5, 2010, at 5:01 PM, Timmy Chan wrote: i have 4 tables, a, b, c, d. a has one-to-many relation with b, b with one-to-one relationship with c, c is a polymorphic on a.type, with d being one of the polymorphic types. is there a way to implement this? details: this is what im

Re: [sqlalchemy] Polymorphic on another table?

2010-05-05 Thread Timmy Chan
thx, is there a way to set that up, or something similar? after giving it thought, maybe polymorphic_on isn't what i need. in some sense, table A is similar to a generic container, and i want to constrain the type of C depending on A's type column. is there a way to do this? On Wed, May 5,

Re: [sqlalchemy] Polymorphic on another table?

2010-05-05 Thread Michael Bayer
what query do you want to see when you select C and D objects ? On May 5, 2010, at 5:26 PM, Timmy Chan wrote: thx, is there a way to set that up, or something similar? after giving it thought, maybe polymorphic_on isn't what i need. in some sense, table A is similar to a generic

Re: [sqlalchemy] Polymorphic on another table?

2010-05-05 Thread Timmy Chan
C/D objects doesn't exist without A and B? maybe walk up the graph: C.b.a.type im not sure this schema is sensible, if it's really bad, please advise, im not attached to it! thax! On Wed, May 5, 2010 at 5:28 PM, Michael Bayer mike...@zzzcomputing.comwrote: what query do you want to see when

Re: [sqlalchemy] Polymorphic on another table?

2010-05-05 Thread Michael Bayer
I meant SQL.if you want to do polymorphic_on based on a.type it would at the very least need to issue: SELECT c.*, a.type JOIN b ON c.b_id = b.id JOIN a ON b.a_id=a which is an expensive way to get to where you're going. It can be done of course but not through relation(). On May 5,

Re: [sqlalchemy] Polymorphic on another table?

2010-05-05 Thread Timmy Chan
thx, that is what i am wondering. they are one-to-one, maybe thats good enough for performance. so there's no easy way to do this. On Wed, May 5, 2010 at 5:44 PM, Michael Bayer mike...@zzzcomputing.comwrote: I meant SQL.if you want to do polymorphic_on based on a.type it would at the