web2py / pydal

A pure Python Database Abstraction Layer
BSD 3-Clause "New" or "Revised" License
493 stars 137 forks source link

The 'fixed pickle raw' break db.tableName usage #668

Open jvanbraekel opened 3 years ago

jvanbraekel commented 3 years ago

Hello,

The 'fixed pickle raw' commit : b9277a41940f34cb43203e4b7285f157fa26b4df, break the db queries of type db(db.TableName.field == value) . While db(db.TableName.id == request.vars.id) is broken, the equivalent db.TableName(request.vars.id) is still fine trough. However there is not always an existing equivalent; for instance for select on non id fields or when the render() function is used afterwards.

Following an example of errors I get :

File "/opt/apps/web2py/gluon/restricted.py", line 219, in restricted exec(ccode, environment) File "/opt/apps/web2py/applications/.../controllers/controllername.py", line 206, in File "/opt/apps/web2py/gluon/globals.py", line 430, in self._caller = lambda f: f() File "/opt/apps/web2py/applications/.../controllers/default.py", line 159, in ... current_object = db(db.TableName.id == request.vars.id).select().render(0,fields=[db.TableName.field]) File "/opt/apps/web2py/gluon/packages/dal/pydal/objects.py", line 3571, in render row[field._tablename][field.name], File "/opt/apps/web2py/gluon/packages/dal/pydal/objects.py", line 146, in getitem raise KeyError(key) KeyError: 'TableName'

The only solution I have at the moment is to roll back to the previous commit , namely : 7237a873d66e7798f88fcd19ec06304e3d19c70f

leonelcamara commented 2 years ago

@mdipierro this "fix" for pickle raw is also the cause of web2py cache disk tests failing.

Other people looking at this note that simply going back to a previous commit is not ideal as there were security patches since then.

mdipierro commented 2 years ago

I cannot reproduce this. I need an example. Possibly an example using pydal only, not web2py