> On Dec 12, 2014, at 7:11 AM, Mainak Sarcar <[email protected]> wrote: > > Hi, > > I have a column_property defined on a model with a select expression as > explained in the examples in > http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#using-column-property. > I had to add an extra condition to the where clause with a bindparam. I have > also defined the column_property with the "deferred=True", so that the query > is not fired in the first place. > > I am able to perform queries by using the "undefer" option in the query > instance and also passing the param to the query. But when I create an > instance of the model and flush and then try to access the column_property, > the query tries to get fired and throws exception complaining about the > bindparam value not being passed.
> > Is there a way I can explicitly prevent the column_property query being fired > for an object that is newly created. I’m puzzled here, the object is flushed, meaning it now has a database identity. Then, I’m assuming either the column_property has never been accessed before, so there is no value in __dict__, or you did a commit(), which expired everything, so there’s nothing in __dict__. Then you access it, which implies you’d like it to return a value of some kind. However, the property has an unset bound parameter. What would the correct value be? If there is no correct value, then what are you expecting to happen when you access this property? It sounds like what you really want here is a hybrid: http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/hybrid.html <http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/hybrid.html> -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
