On Jul 7, 2010, at 1:53 PM, Lance Edgar wrote:

> OMichael, thanks for the tip.  I still found this somewhat confusing
> though:
> 
> When my code runs, the mapper has already been created (and
> "compiled", I assume).  So what I ended up doing, that seemed to work,
> is:
> 
> class_mapper(Order).add_property('quantity',
> column_property(cast(orders.c.quantity, Integer)))
> 
> The thing is, the mapper *already* had a "quantity" property so
> without knowing the internals of that business I can only assume that
> my .add_property() call doesn't have weird side effects (although it
> does accomplish what I'm after).  The mapper exposes .get_property()
> and .iterate_properties(), and of course .add_property(), but I guess
> I would have expected there to be a .set_property()
> or .update_property().  Is this just a quirk in the wording or my
> understanding, or am I still missing some important step?

It's add_property() since you are adding a new property to the existing 
collection of properties.   It is not really intended for the "replacement" of 
existing properties as that has direct impact on the instrumentation of the 
mapped class.   It probably works in the simple case here, but would be better 
if you were to define it "inline" with the original Order mapper.


-- 
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.

Reply via email to