Sorry to bump this up, but I have not been able of using unique as it is described here (no validators).
Also I have tried to use instead of unique IS_NOT_IN_DB as in this other thread is suggested: https://groups.google.com/forum/?fromgroups=#!searchin/web2py/gae$20unique/web2py/ZepLjcBowZs/FuKiSYZGzUAJ ; but same results Introducir código aquí...db.define_table('likes', Field('user_id', 'reference users', notnull='True'), Field('post_id', 'reference posts', notnull='True'), Field('unique_key', unique=True, compute= lambda row: "%(user_id)s-%(post_id)s" %row) ) This worked for me in web2py but not in GAE (by the way I don't know if I should add ,'string', after 'unique_key'. Anyway I have tried to add it with same luck). I could check manually if 'unique_key' is already in DB before inserting as Massimo suggested in the other thread, but I prefer not adding more code (I have several unique fields that I would like to fix with a simple solution). What am I doing wrong? Thanks in advance El viernes, 24 de septiembre de 2010 06:50:01 UTC+2, mdipierro escribió: > > yes and no. It will not be enforced at the database level but if you > do not specify validators, it will use it to pick default validator > that enforce the uniqueness at the web2py level > > On Sep 23, 11:17 am, Carl <[email protected]> wrote: > > My db.py includes... > > > > db.define_table('voucher', > > Field('code', 'string', length=128, unique=True, notnull=True, > > required=True), > > .... > > > > Locally on sqlite when I insert a second record with the same 'code' > > as an existing record insert() throws an except. I catch the exception > > and report back to the user. > > > > Locally on dev_appserver the "duplicate" insert() successfully inserts > > a duplicate record; no exception is thrown. > > > > I've looked at the 2nd edition book and this group but can't find > > anything that say that GAE doesn't support unqiue=True. > > > > Can anyone clarify this use of unique=True on GAE? > > And if it's not supported is there a recommended alternative approach? -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

