I'm trying to do the polymorph mapper example, but am I sort of at a block.
Say I got a setup like:
content = Table('content', engine,
Column('id', Sequence('content_seq'), primary_key=True),
Column('title', String(255))
)
product = Table('product', engine,
Column('id', ForeignKey('content.id'), primary_key=True),
Column('price', Float)
)
page = Table('page', engine,
Column('id', ForeignKey('content.id'), primary_key=True),
Column('name', String(255))
)
class Content(object): pass
class Product(Content): pass
class Page(Content): pass
contents = mapper(Content, content)
products = mapper(Product, product, inherits=contents)
pages = mapper(Page, page, inherits=contents)
Now I try to do the query.
product_join = select([content, product], content.c.id == product.c.id)
page_join = select([content, page], content.c.id == page.c.id)
mixed = union(product_join, page_join)
so of course this screws up because the columns don't match up.
How do I get the same column specs, where the fields needed for the union are
Null when they don't exist for the query I'm doing? (note, I know how to get
there by SQL, but not how to make that compatible with sqlalchemy's column
rename/mapping feature, besides, it'd be quite tedious to hand-generate the
query).
Thanks,
Florian
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users