Hello,
Is it possible to declare UNIQUE constraint over many fields and how...
Does using IS_NOT_IN_DB() on the differents fields will work?
...num_part1.requires=IS_NOT_IN_DB(db((db.ref_fnaregistry.num_part1==request.vars.num_part1)
&
(db.ref_fnaregistry.num_part2==request.vars.
UNIQUE applies at the database level. IS_NOT_IN_DB applies during form
validation.
I'm not sure that's going to work. Maybe a custom validator?
http://web2py.com/book/default/chapter/07#Custom-Validators
IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can
limit the records checked to a particular set within the table (see
http://web2py.com/book/default/chapter/07#Database-Validators). However, I'm
not quite sure what you're trying to do here.
On Thursday, June 30, 2011 4:2
On Thu, Jun 30, 2011 at 4:15 PM, Anthony wrote:
> IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can
> limit the records checked to a particular set within the table (see
> http://web2py.com/book/default/chapter/07#Database-Validators). However,
> I'm not quite sure what yo
On Thursday, June 30, 2011 9:43:39 PM UTC-4, Nick Arnett wrote:
>
>
>
> On Thu, Jun 30, 2011 at 4:15 PM, Anthony wrote:
>
>> IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can
>> limit the records checked to a particular set within the table (see
>> http://web2py.com/book
On Thu, Jun 30, 2011 at 6:43 PM, Nick Arnett wrote:
>
>
> On Thu, Jun 30, 2011 at 4:15 PM, Anthony wrote:
>
>> IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can
>> limit the records checked to a particular set within the table (see
>> http://web2py.com/book/default/chapte
On Thu, Jun 30, 2011 at 7:00 PM, Anthony wrote:
>
>
> I don't think web2py automatically creates any indexes -- see
> http://web2py.com/book/default/chapter/06#Indexes.
>
>
It has to! Can't have primary keys without them. But I see what you mean,
looking at the docs.
I guess I will just use th
Custom Validator still seems like the best option:
http://web2py.com/book/default/chapter/07#Custom-Validators
Although I think unique_together is implemented via db constraints.
That seems like a very remote scenario so probably not outlandish that it
takes a little code.
Postgres, at least, a
Db.define_table('foo',Field('a'),Field('b'), Field('ab',unique=True,
compute=lambda r: r.a + r.b))
http://zerp.ly/rochacbruno
Em 30/06/2011 23:04, "Nick Arnett" escreveu:
> On Thu, Jun 30, 2011 at 6:43 PM, Nick Arnett
wrote:
>
>>
>>
>> On Thu, Jun 30, 2011 at 4:15 PM, Anthony wrote:
>>
>>> IS_N
>Validators, by the way, are >enforced at the form level and
> have no direct effect on the db.
There are 3 levels of validation.
Db validadors:
Unique, notnull, expression etc
Dal validators:
Required, compute, default etc
Form & dal validators:
IS_IN_DB etc..
Note the former will be checked
On Fri, Jul 1, 2011 at 1:20 AM, Bruno Rocha wrote:
> Db.define_table('foo',Field('a'),Field('b'), Field('ab',unique=True,
> compute=lambda r: r.a + r.b))
>
This failed for me with sqlite and I see from other discussions that the
same is true with Django - sqlite throws an error that it cannot cre
This solution work well at least with Postgres.
Richard
On Mon, Jul 11, 2011 at 10:34 AM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:
> Just to close this thread nicely, here the solution I found (thanks to
> Bruno for concatenation :)
>
> import datetime
> now = datetime.datetime.today
This does not create a unique constrain on 'a' and 'b', it is noting like
running the command ALTER TABLE umultiple ADD CONSTRAINT test_unique UNIQUE
(a, b)! it create and extra column in the column in the table alled 'ab'
and puts the unique constrain on that! if you follow this approch for eve
13 matches
Mail list logo