[storm] Fwd: Re: Re: multiple join's

BožoDragojevič bozo.dragojevic at gmail.com
Tue Jan 20 00:10:36 GMT 2009


Justin Warren <daedalus at ...> writes:

> 
> On Wed, 2009-01-14 at 23:58 +0000, Gordon Allott wrote:

> > An or works, I would expect it to, but what I need is an and (or
> > something like it), an or would return companies where any of the
> > employee's listed existed and I need just the companies where all of
> > the employee's listed exist, I think that's what is confusing the issue
> > slightly.
> 
> You want to find all the companies that have *all 3* employees, right?
> 

You can also do intersections with JOINs:

from storm.locals import ClassAlias, Join, And

def has(emp):
  Emp = ClassAlias(Employee)
  return Join(Emp, And(Emp.company_id == Company.id,
                       Emp.name.like(emp)))

origin = [Company, has(u'Ben%'), has(u'Steve%'), has(u'John%')]

companies = store.using(*origin).find(Company)


There are probably also more inefficient ways to do this :-)

Bozzo




More information about the storm mailing list