I know, that's what I'm saying.... the word "where" suggests it is an SQL
verb but it has nothing to do with SQL.  I was just thinking it might be
confusing to new users of w2p.


On Wed, Oct 28, 2009 at 6:32 AM, mr.freeze <nat...@freezable.com> wrote:

>
> No, anything post 'select' is done after the db call, including first
> () and last().
>
> On Oct 28, 2:51 am, Joe  Barnhart <joe.barnh...@gmail.com> wrote:
> > I love the functionality, but doesn't calling the function "where"
> > conjure up the SQL WHERE clause?  I might think it was doing something
> > with SELECT...WHERE in the underlying DB.
> >
> > -- Joe B.
> >
> > On Oct 27, 10:11 pm, "mr.freeze" <nat...@freezable.com> wrote:
> >
> > > Works! Would you be interested in these for sql.py Rows class?:
> >
> > > def where(self,f):
> > >     if not self.response:
> > >         return None
> > >     rows = []
> > >     for i in range(0,len(self)):
> > >         row = self[i]
> > >         if f(row): rows.append(self.response[i])
> > >     return Rows(self._db,rows,*self.colnames)
> >
> > > def filter(self,f):
> > >     if not self.response:
> > >         return None
> > >     rows = self.response
> > >     removed = []
> > >     for i in range(0,len(self)):
> > >         row = self[i]
> > >         if f(row):
> > >             removed.append(rows[i])
> > >             rows.remove(rows[i])
> > >     return Rows(self._db,removed,*self.colnames)
> >
> > > Example:
> > > db.define_table('things',Field('category'))
> > > rows = db(db.things.id>0).select()
> > > tests = rows.where(lamdba row: row.category=="test") # returns matches
> > > rows.filter(lamdba row: row.category=="test")# removes and returns
> > > removed
> >
> > > On Oct 27, 10:49 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> >
> > > > Thanks. Just fixed in trunk!
> >
> > > > On Oct 27, 10:35 pm, "mr.freeze" <nat...@freezable.com> wrote:
> >
> > > > > I get a syntax error when using this. I believe line 2926 of
> > > > > Rows.__getitem__ needs to be changed from:
> >
> > > > > if i >= len(self.response) or i < 0:
> >
> > > > > ...to...
> >
> > > > > if i >= len(self.response):
> >
> > > > > since Rows.last() returns self[-1]
> >
> >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to