Suppose I have an model like:
db.define_table(
'dog',
Field('name'),
Field('type'),
Field('vaccinated', 'boolean', default=False),
Field('picture', 'upload', default=''),
format = '%(name)s')
and a controller like:
@auth.requires_login()
def dogtest():
theId = None
form=SQLFORM.factory(
Field('dogid', label='Name',
requires=IS_IN_DB(db(db.dog), 'dog.id', '%(name)s')),
)
if form.process().accepted:
theId = form.vars.dogid
if not isinstance(theId, int):
response.flash = 'datatype test fail'
form.errors.dogid = 'wrong datatype for id'
return dict(form=form)
I would expect that due to the validation rule for 'dogid' being
constrained to be a db.dog.id that its datatype should match (i.e int).
However the code above triggers the 'wrong datatype for id' error (it is in
fact a str).
Is this expected? I was blithely thinking that it would be typed to match
the corresponding validation field.
--