If I do it on a fresh table it throws exception. I have not turned off
migrations. So I guess changes to unique etc. do not propogate to the
database.

On Jun 14, 4:32 pm, Anthony <[email protected]> wrote:
> Did you add unique=True sometime after the table was originally defined, and
> then turn off migrations? Since it affects the db schema, I don't think you
> can change it after the table is initially created without doing a migration
> (actually, I'm not sure if migrations handle changes to unique, notnull,
> etc.). Otherwise, could be a bug.
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, June 14, 2011 11:07:32 AM UTC-4, apple wrote:
> > 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

Reply via email to