On Aug 6, 2013, at 8:14 PM, Victor Reichert <vfr...@gmail.com> wrote:

> Hi,
> 
> I'm running:
> 
> selected_eventids = []
> 
> selected_event = 
> self.session.query(Master_Simulation_Event).filter(Master_Simulation_Event.cumulative_probability
>  >= selection_percentile, 
> Master_Simulation_Event.event_id.notin_(selected_eventids) ).\
>                 order_by(Master_Simulation_Event.cumulative_probability - 
> selection_percentile).first()
> 
> And it generates:
> 
> 2013-08-06 18:03:43,196 INFO sqlalchemy.engine.base.Engine SELECT TOP 1 
> master_simulation_events.id AS master_simulation_events_id, 
> master_simulation_events.event_id AS master_simulation_events_event_id, 
> master_simulation_events.rate AS master_simulation_events_rate, 
> master_simulation_events.sample_probability AS 
> master_simulation_events_sample_probability, 
> master_simulation_events.cumulative_probability AS 
> master_simulation_events_cumulative_probability 
> FROM master_simulation_events 
> WHERE master_simulation_events.cumulative_probability >= ? AND 
> master_simulation_events.event_id != master_simulation_events.event_id ORDER 
> BY master_simulation_events.cumulative_probability - ?
> 2013-08-06 18:03:43,196 INFO sqlalchemy.engine.base.Engine 
> (0.19528160149168805, 0.19528160149168805)
> 
> The important part is the notin_([]) is translated to:  
> master_simulation_events.event_id != master_simulation_events.event_id
> 
> I recieve the following warning:
> 
> C:\Python27\lib\site-packages\sqlalchemy\sql\expression.py:1982: SAWarning: 
> The IN-predicate on "master_simulation_events.event_id" was invoked with an 
> empty sequence. This results in a contradiction, which nonetheless can be 
> expensive to evaluate.  Consider alternative strategies for improved 
> performance.
>   return o[0](self, self.expr, op, *(other + o[1:]), **kwargs)
> 
> While it doesn't make a lot of sense to pass an empty list to an in_ clause I 
> think passing an emtpy list list to notin_ clause is OK and it shouldn't be 
> replaced.

fixed in 3302187fea0ffd431b980081e7bc483ea364da2b (0.8.3) and 
34ef21909bd6ed3574e37c345ca9e (master).  You don't really need "notin" in any 
case, just use ~col.in_([]) for now.


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to