Thank you Anthony. I always appreciate your input.

I recall using the aggregates max() and count() before and they worked fine 
following the book. That was quite long ago. However, this time, I did not 
try on the "old" web2py version. I upgraded to 2.15.1 and continued to code 
in it.

Using
db(db.table).select(max)



Gave a longer traceback:
Traceback (most recent call last):
  File "/Users/web2py/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "<string>", line 83, in <module>
  File "/Users/web2py/web2py/gluon/globals.py", line 422, in write
    self.body.write(to_native(xmlescape(data)))
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.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'



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