These: db.testtable.name.requires=IS_NOT_IN_DB(db, db.testtable.name) db.testtable.name.requires = IS_ALPHANUMERIC()
shuld be db.testtable.name.requires= (IS_ALPHANUMERIC(),IS_NOT_IN_DB(db, db.testtable.name)) otherwise the second requires overrides the previous ones, web2py checks only for IS_ALPHANUMERIC, not uniqueness and the database checks for uniqueness raising an exception. On Jun 16, 12:27 am, matt grham <matt.gr...@gmail.com> wrote: > Hi All, > > The following table definition does not work all the time. Sometimes > it gives the following error: IntegrityError: column name is not > unique. I want to receive the error at the form level. > > db.define_table('testtable', > Field('name', 'text', unique=True, notnull=True), > migrate=True) > > db.testtable.name.requires=IS_NOT_EMPTY() > db.testtable.name.requires=IS_NOT_IN_DB(db, db.testtable.name) > db.testtable.name.requires = IS_ALPHANUMERIC() > > Note: If I comment db.testtable.name.requires = IS_ALPHANUMERIC(), I > can get the error at the form level. > > Did anybody observe this behavior? I am using sqlite database.