Workaround it like that : if someflag: try: base_date = db.other_table.received_timestamp.date() except: base_date = db.other_table.date columns = [(db[table].date - base_date).avg().with_alias('avg_date')] # Works YEAH! else: columns = [(db[table].date - db.other_table.date.date()).avg().with_alias('avg_date')]
Richard On Wed, Oct 21, 2015 at 12:02 PM, Richard <ml.richard.vez...@gmail.com> wrote: > Hello, > > I think I just hit a limitation with web2py dal select query build with > conditions... > > Here the issue: > > if someflag: > columns = [(db[table].date - > db.other_table.received_timestamp.date()).avg().with_alias('avg_date')] # > This one does work > # Failed on : 'Field' object has no attribute 'date' > columns = [lambda: (db[table].date - > db.other_table.received_timestamp.date()).avg().with_alias('avg_date')] # > This one does work neither > # Failed on : 'function' object has no attribute 'type' > else: > columns = [(db[table].date - > db.other_table.date.date()).avg().with_alias('avg_date')] # This one works > > db(...).select(*columns) > > Is there a way to make aggregate lazy somehow? > > Thanks a lot > > Richard > > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.