Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2013-11-14 Thread Ida N
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

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-07-11 Thread Richard Vézina
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()

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-07-02 Thread Nick Arnett
On Fri, Jul 1, 2011 at 1:20 AM, Bruno Rocha rochacbr...@gmail.com 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

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-07-01 Thread Bruno Rocha
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 nick.arn...@gmail.com escreveu: On Thu, Jun 30, 2011 at 6:43 PM, Nick Arnett nick.arn...@gmail.com wrote: On Thu, Jun 30, 2011 at

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-07-01 Thread Bruno Rocha
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 in

[web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Richard Vézina
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)

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread pbreit
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

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Anthony
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

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Nick Arnett
On Thu, Jun 30, 2011 at 4:15 PM, Anthony abasta...@gmail.com 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

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Anthony
On Thursday, June 30, 2011 9:43:39 PM UTC-4, Nick Arnett wrote: On Thu, Jun 30, 2011 at 4:15 PM, Anthony abas...@gmail.com 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

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Nick Arnett
On Thu, Jun 30, 2011 at 6:43 PM, Nick Arnett nick.arn...@gmail.com wrote: On Thu, Jun 30, 2011 at 4:15 PM, Anthony abasta...@gmail.com 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

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Nick Arnett
On Thu, Jun 30, 2011 at 7:00 PM, Anthony abasta...@gmail.com 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

Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread pbreit
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,