Why not implement it as the others? db.test.number.average()
On Oct 13, 11:59 pm, "mr.freeze" <[email protected]> wrote: > What about a generic sql function for Field? Here is a proof of > concept: > ------------------------- > def sql(self, name, data_type, *args): > out = '' > if args: > out = "," + ",".join([str(a) for a in args]) > return Expression('%s(%s%s)' % (name, str(self), out), data_type, > self._db) > ------------------------- > test = db(db.test.id > 0).select(db.test.number.sql("AVG",'double')) > ------------------------- > {{for t in test:}} > {{=str(t._extra['AVG(test.number)'])}} > <br /> > {{pass}} > ------------------------- > > The syntax needs to be cleaned up and integrated better but you get > the idea. What do you think? > > On Oct 13, 10:12 pm, mdipierro <[email protected]> wrote: > > > On Oct 13, 9:02 pm, "mr.freeze" <[email protected]> wrote: > > > > This has probably been asked before but why doesn't the Field class > > > have these?: > > > no > > > > avg, format, round, mid, len, first, last > > > > Is it because they are not common to all databases? > > > yes > > > probably avg and round should be implemented since they are common. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

