alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

New dal.py & options widget: Set: no tables selected #134

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From reingart@gmail.com on December 09, 2010 22:19:42

What steps will reproduce the problem? db.define_table('tipo_cbte', Field('cod', type='id'), Field('desc'), Field('discriminar', 'boolean'), format="%(desc)s", migrate=migrate, )

db.define_table('comprobante', Field('id', type='id'), Field('webservice', type='string', length=6, default='wsfe', requires = IS_IN_SET(WEBSERVICES)), Field('fecha_cbte', type='date', default=request.now.date(), requires=IS_NOT_EMPTY(), comment="Fecha de emisión"), Field('tipo_cbte', type=db.tipo_cbte,), )

form = SQLFORM(db.comprobante) http://code.google.com/p/pyafipws/source/checkout?repo=web2py-app What is the expected output? What do you see instead? Traceback (most recent call last): File "/home/mariano/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/home/mariano/web2py/applications/fe/controllers/emision.py", line 76, in File "/home/mariano/web2py/gluon/globals.py", line 95, in self._caller = lambda f: f() File "/home/mariano/web2py/applications/fe/controllers/emision.py", line 15, in iniciar form = SQLFORM(db.comprobante, session.comprobante_id, fields=campos_generales) File "/home/mariano/web2py/gluon/sqlhtml.py", line 792, in init inp = self.widgets.options.widget(field, default) File "/home/mariano/web2py/gluon/sqlhtml.py", line 205, in widget options = requires[0].options() File "/home/mariano/web2py/gluon/validators.py", line 424, in options self.build_set() File "/home/mariano/web2py/gluon/validators.py", line 408, in build_set records = self.dbset.select(_self.fields, *_dd) File "/home/mariano/web2py/gluon/dal.py", line 4369, in select return self.db._adapter.select(self.query,fields,attributes) File "/home/mariano/web2py/gluon/dal.py", line 976, in select query = self._select(query,fields,attributes) File "/home/mariano/web2py/gluon/dal.py", line 911, in _select raise SyntaxError, 'Set: no tables selected' SyntaxError: Set: no tables selected

Attachment: dal-nts.diff

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

alfonsodg commented 10 years ago

From massimod...@gmail.com on December 09, 2010 19:45:12

I put your fix in trunk and it works but I do not understand. How come query is a string in the IS_IN_DB(...).dbset? It should not be happening. I am concerned something else may be broken because of this.

alfonsodg commented 10 years ago

From massimod...@gmail.com on December 09, 2010 21:19:44

I believe this is fixed although I had to use a different solution. The solution you proposed had a problem because of recursion in adapter.tables

Status: Fixed

alfonsodg commented 10 years ago

From reingart@gmail.com on December 09, 2010 21:32:07

Yes, you are right, that quick patch brokes other things:

Traceback (most recent call last): File "/home/mariano/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/home/mariano/web2py/applications/welcome/controllers/default.py", line 55, in File "/home/mariano/web2py/gluon/globals.py", line 95, in self._caller = lambda f: f() File "/home/mariano/web2py/applications/welcome/controllers/default.py", line 17, in index return plugin_flatpage() File "/home/mariano/web2py/applications/welcome/models/plugin_flatpages.py", line 54, in plugin_flatpage rows = db(query).select(orderby=~db.plugin_flatpage.created_on, limitby=(0, 1)) File "/home/mariano/web2py/gluon/dal.py", line 4379, in select return self.db._adapter.select(self.query,fields,attributes) File "/home/mariano/web2py/gluon/dal.py", line 984, in select sql = self._select(query,fields,attributes) File "/home/mariano/web2py/gluon/dal.py", line 908, in _select for field in self.db[table]: File "/home/mariano/web2py/gluon/dal.py", line 3325, in getitem return dict.getitem(self, str(key)) KeyError: 'default'

I've tested your last patch and it seems working fine.

alfonsodg commented 10 years ago

From massimod...@gmail.com on December 09, 2010 21:34:19

Your patch pointed me to the right direction. Thanks for checking.