alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

Misleading exception message with SQLTABLE and columns (KeyError _extra) #132

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From reingart@gmail.com on December 02, 2010 00:53:18

What steps will reproduce the problem? 1. rows = db(...).select(...)

  1. SQLTABLE(rows, columns=['inexistent_column']) What is the expected output? What do you see instead? An exception with an useful message (like KeyError or RuntimeError). It raises an exception, but saying _extra is missing, witch is a little frustrating to detect the correct error. What version of the product are you using? On what operating system? web2py hg trunk Please provide any additional information below. Traceback (most recent call last): File "C:\web2py-src\web2py-hg\gluon\restricted.py", line 188, in restricted exec ccode in environment File "C:\web2py-src\web2py-hg\applications\pyafipws/views\emision/detalle.load", line 2, in columns=['codigo','qty','umed','precio','imp_total','iva_id','ds', 'ncm', 'sec', 'bonif'], File "C:\web2py-src\web2py-hg\gluon\sqlhtml.py", line 1271, in init r = record._extra[colname] File "C:\web2py-src\web2py-hg\gluon\sql.py", line 742, in getattr return dict.getitem(self,key) KeyError: '_extra'

Message with the proposed patch:

Traceback (most recent call last): File "C:\web2py-src\web2py-hg\gluon\restricted.py", line 188, in restricted exec ccode in environment File "C:\web2py-src\web2py-hg\applications\pyafipws/views\emision/detalle.load", line 7, in 'detalle.ncm':'NCM', 'detalle.sec':'SEC', 'detalle.bonif':'Bonif.'}, File "C:\web2py-src\web2py-hg\gluon\sqlhtml.py", line 1276, in init raise KeyError("Column %s not found (SQLTABLE)" % colname) KeyError: 'Column codigo not found (SQLTABLE)'

Workaround: Don't forget to add table name to columns name ('detalle.codigo' instead of 'codigo' alone, that was the error in this case).

Attachment: sqltable_extra_keyerror.diff

Original issue: http://code.google.com/p/web2py/issues/detail?id=133

alfonsodg commented 10 years ago

From massimod...@gmail.com on December 02, 2010 20:53:57

Status: Fixed

alfonsodg commented 10 years ago

From massimo....@gmail.com on June 20, 2011 11:26:37

I believe this has been fixed long ago. Please reopen if this is still an issue

Status: Invalid