On May 21, 2008, at 12:50 AM, andrew cooke wrote:
> > > Hi, > > Just wanted to check: I am seeing a NotImplementedError (v 0.4.6 on > Linux w Python 2.5) when I try to query some objects with the filter > "in". Does that mean that the feature is not implemented, or is it > more likely an error in my code (eg somehow I'm calling a base class; > "Address.email_address.in_" does appear in the ORM tutorial, which > makes me wonder whether it is supported)? > > If this is unsupported, what's the best approach? Just loop over the > various instances myself? > > My code looks like: > > query = session.query(Measurement) > query = query.filter(Measurement.time_series.in_(time_series)) in_ is supported for column-based attributes. If you are getting NotImplemented, that's beacuse "time_series" is referencing either a collection or a many-to-one object reference. so SQL "IN" wouldn't work here. For the many-to-one case, "IN" could be implemented in SQLA easily if the referenced object had a single-column primary key, but for a composite primary key we dont yet support the (x, y, z) IN ((a,b,c), (d,e,f)) syntax (not sure of DB support for that either). So in this case (assuming time_series is a many-to-one) you need to use or_(): or(*[Measurement.time_series==x for x in time_series]) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---