Let's say I want to have a simple calculated property in my class, eg. amount which is just qty * price.
I can define it as a column_property in a mapper which makes it available in all database operations, eg. I can write session.query (myclass).filter_by(amount>1000) which will create the correct WHERE clause "qty*price>1000". However, the attribute is None until the object is flushed to the database, ie. myclass.qty = 2 myclass.price = 500 print myclass.amount will return None if flush was not issued. If I use a Python property function to define it, it will be immediately available (and always up to date); however, I cannot query on a Python property. Is there a way to have best of both worlds? Or should I just define the calculated property twice, eg. Python property named 'amount' and a column_property named 'db_amount' and then work with the first but use the second for querying?
-- 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.