The problem is that when you set a length=1 you should get a default
IS_LENGHT(1) validator but because you specify the IS_UPPER() validator you
override the default. This will do what you ask:
Field('name', 'string', length=1, requires=(IS_LENGTH(1),IS_UPPER()))
Without the check sqlite may allow you to store longer strings in there.
Not sure.
On Monday, 21 January 2013 07:43:12 UTC-6, www.diazluis.com wrote:
>
> when implemented the following code, I notice that the system does not
> respect
> the length of the field in the database.
>
> if the user enters a name of more than one (1) character the system stores
> ..
>
> wonder: is this a bug?
>
> to the following model:
>
> auth_user_id = (auth.user and auth.user.id) or None
>
> db.define_table('table_x',
> Field('name', 'string', length=1, requires= IS_UPPER()),
> Field('auth_user', db.auth_user, default=auth_user_id,
> writable=False, Readable=False),
> )
>
> using the controller:
>
> def index ():
> form = SQLFORM.factory(
> Field('name', 'string', length=3, requires=IS_UPPER()),
> )
>
> if form.accepts (request.vars):
> db(db.table_x.auth_user==auth_user_id).update(name=
> request.vars.name)
>
> return dict (form = form)
>
--