Except it has not resulted in an error and has added two rows to the database with the same name.
On Jun 14, 3:47 pm, Anthony <[email protected]> wrote: > On Tuesday, June 14, 2011 10:38:49 AM UTC-4, apple wrote: > > > The following code in a model results in two rows with the name > > "test". So what does unique=True do? > > It translates to the "UNIQUE" SQL statement and is enforced at the level of > the database. requires=IS_NOT_IN_DB, on the other hand, is a validator and > is enforced by web2py forms. If you make insertions into the database > without using a form, unique=True will still be enforced by the database, so > duplicate values will result in an error (and the transaction will not be > committed). > Seehttp://web2py.com/book/default/chapter/06#Record-Representation. > > Anthony

