You need to do:

included = db.Table('included', Field('uniq', unique=True))
including = db.define_table('including', included, Field('field1'))
including.uniq.requires=IS_NOT_IN_DB(db,'including.uniq')

The last line is necessary because it is not obvious that you want to
be unique respect to the derived table and not the base table.
Actually it is obvious because the base table is "virtual" but the
table itself does not know.



On Oct 12, 4:00 pm, nick name <i.like.privacy....@gmail.com> wrote:
> Note: tested on 1.97.1; I believe problem (or my misunderstanding) is still
> on trunk. I tried to check with trunk, but I have some compatibility
> problems to solve first - I will post an update when I have solved them.
>
> I have an included table defined like this:
>
> included = db.Table('included', Field('uniq', unique=True))
>
> including = db.define_table('including', included, Field('field1'))
>
> Now, I can't use the admin (or any web2py validation such as
> validate_and_insert) to edit the "including" table -- the validators for the
> "uniq" field was generated when "included" table was defined, and it is a
> "IS_NOT_IN_DB()" referring the nonexisting "included" table. Other
> validators like "IS_NOT_EMPTY()" are fine, but validators referring to the
> database are not.
>
> Does this description sound right?

Reply via email to