On Jan 14, 2009 4:41pm, Gordon Allott [email protected]> wrote:
> On Wed, 2009-01-14 at 16:18 -0700, Alex Richardson wrote:
>
> > On Wed, Jan 14, 2009 at 3:56 PM, Gordon Allott [email protected]>
wrote:
>
> > Gordon,
>
> >
>
> > There are two different topics that I think your posting touches on.
>
> >
>
> > First is the question of who to use a join in a query. The tutorial
>
> > code you refer to properly demonstrates this. And it sounds like you
>
> > don't have any trouble getting the table join to work.
>
> >
>
> > The second question is how to build a 'where' clause to select the
>
> > appropriate rows. In the simple example above, you could use the
>
> > following code to find the companies for Ben, Steve, and Jon:
>
> >
>
> > origin = [Company, Join(Employee, Employee.company_id == Company.id)]
>
> > result = store.using(*origin).find(Company,
>
> > (Employee.name.like(u"Ben%") | (Employee.name.like(u"Ben%") |
>
> > (Employee.name.like(u"Ben%") ) )
>
> >
>
> > Note that the pipe operator '|' is shorthand for the more
>
> > verbose/explicit use of the 'Or' method.
>
> >
>
> > result = store.using(*origin).find(Company,
>
> > Or(Employee.name.like(u"Ben%"), (Employee.name.like(u"Ben%"),
>
> > (Employee.name.like(u"Ben%") ) )
>
> >
>
> > The use of 'and', 'or' and 'in', to build more complex where clauses
>
> > is touched upon in the storm manual.
>
> > (https://storm.canonical.com/Manual)
>
> >
>
> > Alex Richardson
>
>
>
> yes, but this method seems not to work, At the moment I am building up a
>
> list that looks similar to: (like is not actually needed in my
>
> situation)
>
> employees = [Employee.name == u'Ben', Employee.name == u'Steeve',
>
> Employee.name == u'John']
>
>
>
> neither of the following work:
>
> store.using(*origin).find(Company, *employees)
>
> store.using(*origin).find(Company, And(employees))
>
>
>
> although the following does:
>
> store.using(*origin).find(Company, Employee.name == u'Ben')
>
> # u'Steeve' and u'John' would work on their own also.
>
> --
>
> Gordon Allott ([email protected])
>
Gordon, yes, the examples you are providing would not work. You need to
provide a single where clause, so your first example does not work.
store.using(*origin).find(Company, *employees)
Your second example uses an 'And' which means you are trying to match an
employee row where the name is 'Ben' AND ' Steeve' AND 'John'. An
employee's ame can not match all three values, so it always fails and you
get back 0 rows.
However, if you change to an 'Or' it should work. Then you are trying to
match an employee row where the name is 'Ben' OR ' Steeve' OR 'John'.
So I would expect something along the following to work:
store.using(*origin).find(Company, Or(*employees))
Alex
PS Accidently sent this response directly to Gordon. Forwarding it to the
list so someone can correct me if I'm wrong.
--
storm mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/storm