existing = db(db.person.id==desired_id).select().first()
if existing and existing.name != request.vars.name:
    existing.update_record(name=request.vars.name)



On Mar 21, 9:38 am, Matthew <matthew.g.nor...@gmail.com> wrote:
> Is there a clean way to update a record only if it is different than
> the proposed changes?
>
> For example, I have a person in the table 'person' whose name is
> 'Pete'. To update his name:
>
> desired_id = 5
> db(db.person.id == desired_id).update(name='Pete')
>
> Update is executed, even though his name did not change. What's the
> cleanest way to not do the update if the record's fields have not
> changed?
>
> Thanks,
> Matthew

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to