if youre working with 0.2, ive committed some big changes today partially in response to this issue, including a unit test that tests the ability to override columns and have them propigate....you might want to try it and see if you have better luck.

On May 18, 2006, at 11:14 AM, Marty McFly wrote:

Hi,

Thanks for the fast answer, Mike! Another small, maybe related question. Let's say that I override the column names in the mapper of my base class, for example 'body' instead of 'text', like this:

TextItem.mapper = mapper(TextItem, text_items,
                    properties = {'body' : text_items.c.text}
                    )
Post.mapper = mapper(Post, posts,
                     inherits=TextItem.mapper,
                     )

When I specify the inheritance as above, the Post.mapper doesn't use the name override of the base class, so text_items.c.text got mapped to 'text' instead of 'body' (in the Post class). Wouldn't it make sense for the inherited mapper to inherit the names (and not just the sql-columns) as well? Otherwise you have to duplicate all your renamed properties in your inheriting class, which I would like to avoid in an OO-context (Post inherits from TextItem, so the attributes should have the same name).

Well, even though I am a newbie and still have lots of questions...: just wanted to say that I really like SQLAlchemy and I think it is a great product. Thanks for all the development and also the help on the mailing list!

Cheers, Martin




Von: Michael Bayer <[EMAIL PROTECTED]>
An: "Marty McFly" <[EMAIL PROTECTED]>

its because your post mapper is using joined table inheritance, i.e.
joining text_items to posts.  so the primary key of "text_items JOIN
posts on text_items.id==posts.id" is a composite of "text_items.id,
posts.id".  So.....it considers the primary key of Post id #1 to be
this:

 m.get(1,1)

or in 0.2, like:

 m.get((1,1))

there is the notion that the primary key of such a join should only
use the single column from "text_items", since the primary key of
"posts" is also the foreign key thats being related to text_items;
its redundant and thats why you intuitively used only one primary key
value in your get() (and also why get_by works).

but it seems like Join object is going to have to analyze the join
condition to see if there is literally a
"table1.primary_key==table2.foreign_and_primary_key" condition since
there are other join conditions with two tables like this where this
rule wouldnt apply.  that will require some elaborate logic.....so i
think you have to stick with the "dual id" thing for the near term.


Schnell und einfach ohne Anschlusswechsel zur Lycos DSL Flatrate wechseln und 3 Monate kostenlos ab effektiven 5,21 EUR pro Monat im ersten Jahr surfen. http://www.lycos.de/startseite/online/dsl/index.html? prod=DSL&trackingID=email_footertxt



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to