~cjwatson/storm/no-string-exceptions

« back to all changes in this revision

Viewing changes to storm/expr.py

  • Committer: Alberto Donato
  • Date: 2016-05-13 09:50:45 UTC
  • mfrom: (482.1.2 expr-is-in-resultset)
  • Revision ID: alberto.donato@canonical.com-20160513095045-a9f1ypirljbncd3v
Merge lp:~ack/storm/expr-is-in-resultset [r=free.ekanayaka].

This change allows to use a subquery (insted of performing two separate queries) when the Comparable.is_in(ResultSet) expression is used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
486
486
        return Neg(self)
487
487
 
488
488
    def is_in(self, others):
489
 
        if not isinstance(others, Expr):
 
489
        from storm.store import ResultSet
 
490
        if isinstance(others, ResultSet):
 
491
            # If a ResultSet is passed, use it for a SELECT subquery, instead
 
492
            # of performing a separate query and passing in the resulting list.
 
493
            others = others._get_select()
 
494
        elif not isinstance(others, Expr):
490
495
            others = list(others)
491
496
            if not others:
492
497
                return False