AFAIK, the polymorphic_identity value there is used:
 a) for queries, to discriminate/switch between object-types
 b) for inserts, to put _that value when inserting that object-type.

i.e. to me these values ought to be some consts, different for each 
subtype in the hierarchy. As of sharing that functionality with 
something else (why is it a FK?), i have no idea.

> I'm busy to play with (joinded) inheritance in SQLAlchemy. I have
> to design and implement a CMS-like app and my idea was to do
> something like (it's the SQL script) :
> http://pastebin.com/m35f5227d
>
> As you can see it's a classic inheritance situation: a base Content
> (abstract) which is of a certain ContentType (the polymorphic_on),
> and more specialized objects (News, Events, ...) inherits from this
> base Content class.
>
> In the manual I read that :
> "The table also has a column called type. It is strongly advised in
> both single- and joined- table inheritance scenarios that the root
> table contains a column whose sole purpose is that of the
> discriminator; it stores a value which indicates the type of object
> represented within the row. The column may be of any desired
> datatype"
>
> In my situation the so-called "type" column is the
> "content_type_id", which is foreign key, so for the News / Content
> relation in this case I would have something like :
>
> mapper(Content, contents,
> polymorphic_on=contents.c.content_type_id,
> polymorphic_identity='?????')
>
> mapper(Engineer, engineers, inherits=Employee,
> polymorphic_identity='?????')
>
> My question is: can I have a select() object which return a scalar
> for the polymorphic_identity parameters ? I guess it should be
> possible to put anything else than the FK value ?
>
> Thanks,
> Julien



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to