Hi All,
I have the following update or insert statement in a controller.
db.grades.update_or_insert(
((db.grades.auth_user == student.id) &
(db.grades.assignment == assignment.id)),
auth_user = student.id,
assignment = assignment.id,
score=score)
The function that this is part of is called as the result of a user
pressing a button on the web page. It could get pressed multiple times in
quick succession. (Yes, I'll fix that too). ButI was surprised that I end
up with duplicate values every now and then. This is on top of Postgresql
with psycopg2 driver. I added a constraint to the table definition to
ensure that user,assignment pairs are unique and now at least I can catch
the IntegrityErrors when they happen.
Since this is running in an multi-process environment I guess I could see
how this might happen, but it seems like a bug. Or am I doing something
stupid?
Brad
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.