On Thursday, January 21, 2016 at 4:57:57 AM UTC-5, Pierre wrote:
>
>
> Hi all,
>
>
> have tried different options to do so but all have failed:
>
> list:reference + unique=True    fails
> list:reference + IS_NOT_IN_DB()    fails
> compute field + unique=True   fails
> compute field + IS_NOT_IN_DB()   fails
>

Are you saying you want to ensure the particular list of references is 
unique per record? Also, what do you mean by "fails" -- causes an error, or 
fails to prevent duplicates?

Note, the "unique" attribute applies to the database, so the database will 
enforce that (throwing an exception if you attempt to insert a duplicate). 
However, the database will only interpret two lists as duplicates if their 
elements are in the same order (this is because list:reference fields are 
actually stored as delimited strings in the database). For example, [1,2,3] 
will not be considered a duplicate of [2,3,1] because the former will be 
stored as "|1|2|3|" and the latter as "|2|3|1|". However, if you attempt to 
insert [1,2,3] (in that exact order) twice, the database should prevent 
that if you have set unique=True.

If you want to handle this via a form validator, you will probably have to 
code a custom validator. Note, though, that it will get tricky if you want 
to consider two lists to be duplicates even if they are in different orders.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to