On Jul 7, 2010, at 1:30 AM, Lance Edgar wrote: > Hi, I was wondering what method might be used (assuming it's possible) > to redefine a column's attribute type after the mapping has already > been made? Specifically I have the following scenario: > > > from sqlalchemy import * > from sqlalchemy.orm import mapper > > metadata = MetaData() > > orders = Table( > "orders", metadata, > Column(id, Integer, primary_key=True), > Column(quantity, Numeric(8,3)), > ) > > class Order(object): > pass > > mapper(Order, orders) > > # ... then later ... > > from sqlalchemy.orm import class_mapper > > class_mapper(Order).get_property('quantity').update_to_integer_type() > > > Obviously that last method doesn't exist, but I would like something > along those lines. Basically I want to type-cast the column at the > ORM layer instead of everywhere it appears in the UI. I can't just > pass Integer to the Column definition because that's happening > elsewhere in another package. Thanks in advance for any suggestions.
map it as column_property(cast(table.c.column, Integer)). -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.