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.
Is this a bug?
~Victor
--
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/groups/opt_out.