On 13 April 2012 16:52, Richard Vézina <ml.richard.vez...@gmail.com> wrote:

> In your model definition if you use :
>
> unique=True
>
> For each field, It should build your db correctly... But maybe you want
> both field together to be unique...
>

I know about 'unique'.  The constraint I used in the example makes the
combination of fields unique.

>
> I don't remember how, but I think there is a way to tell web2py about
> multiple column constraint. I customize validator for doing this... I can
> show a bit the code if you want.
>

Previously I had to use web2py code to do a database lookup before an
insert to make sure that there is not already the same combination in the
table.  Now, I am able to let the database do the work and I do not need an
extra lookup.  Whatever web2py code there may be to solve a problem like
this, it will not be as efficient as that of the database.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Reply via email to