Your params dictionary should only contain what is being updated (except for id which can be there too).
params = { 'name': 'pepe', 'id': 1 } # ok params = { 'name': 'pepe' } # ok params = { 'name': 'pepe', 'id': 1 , 'email': '...'} # error In your case use the first since you are selecting the record using params['id']. On Thursday, December 10, 2015 at 3:58:53 PM UTC-5, argenio.bosa...@metamaxzone.com wrote: > > I have one table in my mysql db with name "users" with this: > id - name - email > 1 - luis - exam...@gmail.com > 2 - steff - he...@gmail.com > > the field email is unique in the DAL > Field('email', 'string', length=255, required=True, notnull=True, > unique=True), > > > when i try to edit the form, I only change my name, but the email it's the > same, ok perfect, > I send 2 parameters, name is diferent and email it's the same in this case > in the bd. > id: 1, name: pepe, email: exam...@gmail.com > > result = db(db.users.id == > params["id"]).validate_and_update(**db.users._filter_fields(params)).as_dict() > > i search the register with the id, perfect, but when "update the email" i > got the error > > <class 'gluon.contrib.pymysql.err.IntegrityError'> (1062, u"Duplicate > entry ' exam...@gmail.com' for key 'email_UNIQUE'") > > because "exam...@gmail.com exist in the databases BUT exist in the > register where I UPDATE, and I send the SAME value because don't change the > email > > maybe you reply if don't have change the register, delete the params and > don't send to DAL and when change send it. > that's it's not a good practice, because when i really change the email > get code innecesary. and I need detecte the change in front page, (ios, > andriod, web, etc) > > now, how can i solved my problems? > > I have one solutions but i don't like: > search the register in DB, read the field email and is the same delete > params and dont send to insert and it's diferente send. > BUT that generate one petition aditional to the server > > summarized: I check manually the unique in db. > > Please I need help, thx very much > note: I dont talk good the english. > > > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.