Anthony, pls 
see https://groups.google.com/d/msg/web2py/h4b4xz2NzNM/QHSoRfrcCAAJ

If we put double quotes on the table name, which happens to not be there 
for *aggregates* and *distinct* then the sql query will work.

On Friday, July 14, 2017 at 5:43:57 AM UTC+8, Anthony wrote:
>
> Are you saying that used to work but doesn't any longer?
>
> How about db(db.table).select(max)?
>
> Anthony
>
> On Thursday, July 13, 2017 at 1:16:31 PM UTC-4, lyn2py wrote:
>>
>> I'm using a simple query to get aggregate:
>>
>> max = db.table.date.max()
>> row = db().select(max)
>>
>> Just following the example here 
>> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum-avg-min-max-and-len
>>
>> But I ran into this error:
>>
>> Traceback (most recent call last):
>>   File "/Users/web2py/web2py/gluon/main.py", line 445, in wsgibase
>>     serve_controller(request, response, session)
>>   File "/Users/web2py/web2py/gluon/main.py", line 180, in serve_controller
>>     page = run_controller_in(request.controller, request.function, 
>> environment)
>>   File "/Users/web2py/web2py/gluon/compileapp.py", line 660, in 
>> run_controller_in
>>     vars = vars.xml()
>>   File "/Users/web2py/web2py/gluon/packages/dal/pydal/objects.py", line 
>> 2497, in xml
>>     rv = self.db.represent('rows_xml', self)
>>   File "/Users/web2py/web2py/gluon/packages/dal/pydal/base.py", line 834, 
>> in represent
>>     return self.representers[name](*args, **kwargs)
>>   File "/Users/web2py/web2py/gluon/sqlhtml.py", line 3319, in __init__
>>     tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
>>   File "/Users/web2py/web2py/gluon/sqlhtml.py", line 3319, in <genexpr>
>>     tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
>> AttributeError: 'Expression' object has no attribute 'tablename'
>>
>>
>> Kindly assist.
>>
>>
>> On Tuesday, July 11, 2017 at 5:40:08 AM UTC+8, Massimo Di Pierro wrote:
>>>
>>> It took a year. Thanks to everybody who contributed. There are a ton of 
>>> bug fixes and speed improvements.
>>>
>>> I would encourage everybody who contributed to add a comment in this 
>>> thread explaining the main features/improvements they have made.
>>>
>>> If anything does not work or was broken it is only fault and I will 
>>> remedy if reported.
>>>
>>> Massimo
>>>
>>

-- 
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.

Reply via email to