db.define_table('houses',
Field('name', 'string', length=100,
requires=IS_NOT_EMPTY()),
Field('ordinal','integer'))
db.define_table('flocks',
Field('name', 'string', length=100,
requires=IS_NOT_EMPTY()),
Field('ordinal','integer'))
db.define_table('flockdata',
Field('flock', db.flocks, requires=IS_IN_DB(db,
db.flocks.id, '%(name)s')),
Field('house', db.houses, requires=IS_IN_DB(db,
db.houses.id, '%(name)s')),
Field('x_count', 'integer', requires=IS_NOT_EMPTY()),
Field('y_count', 'integer', requires=IS_NOT_EMPTY()),
Field('active', 'boolean',
requires=IS_NOT_EMPTY(),default=True))
db.define_table('dailyentry',
Field('flockdata', db.flockdata,requires=IS_IN_DB(
db((db.flockdata.flock==db.flocks.id)&(db.flockdata.house==db.houses.id)),
db.flockdata.id, '%(houses.name)s')),
Field('date','date'),
Field('wumba', 'integer'))
I have two tables, houses and flocks, that are both used as keys in
flockdata. Each day, users will enter information into dailyentry. They
expect to set the proper house/flock combination by choosing 'houses.name'.
The select query below shows me a field named houses.name, but the
IS_IN_DB above will not let me use it.
dailyentry=db((db.flockdata.flock==db.flocks.id)&(db.flockdata.house==db.dailyentry.id)).select()
Traceback (most recent call last):
File "/var/www/web2py/gluon/restricted.py", line 186, in restricted
exec ccode in environment
File "/var/www/web2py/applications/tyc/controllers/dailyinput.py",
line 20, in <module>
File "/var/www/web2py/gluon/globals.py", line 96, in <lambda>
self._caller = lambda f: f()
File "/var/www/web2py/gluon/tools.py", line 2219, in f
return action(*a, **b)
File "/var/www/web2py/applications/tyc/controllers/dailyinput.py",
line 12, in edit
form = SQLFORM(db.dailyentry)
File "/var/www/web2py/gluon/sqlhtml.py", line 724, in __init__
inp = self.widgets.options.widget(field, default)
File "/var/www/web2py/gluon/sqlhtml.py", line 186, in widget
options = requires[0].options()
File "/var/www/web2py/gluon/validators.py", line 422, in options
self.build_set()
File "/var/www/web2py/gluon/validators.py", line 406, in build_set
records = self.dbset.select(*self.fields, **dd)
File "/var/www/web2py/gluon/sql.py", line 3216, in select
rows = response(query)
File "/var/www/web2py/gluon/sql.py", line 3211, in response
db._execute(query)
File "/var/www/web2py/gluon/sql.py", line 947, in <lambda>
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
OperationalError: no such column: flockdata.houses.name
Am I missing something, or is IS_IN_DB being daft?
--
Andrew Thompson
http://aktzero.com/