Opened 10 years ago
Last modified 10 years ago
#22947 closed Uncategorized
transaction rollback not working in django 1.6.5 — at Initial Version
Reported by: | khaihkd | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.6 |
Severity: | Normal | Keywords: | transaction rollback |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Example:
my model: User (id: integer auto increment, name: string, age: integer)
I have a array data insert to database (database is mysql)
[['John', 20], ['Bob', 30], ['Mark', 'not number']]
@transaction.non_atomic_requests()
def update_Ac_Point_Detail(self):
array = [['John', 20], ['Bob', 30], ['Mark', 'not number']]
transaction.set_autocommit(False)
for item in array:
try:
user = User()
user.name = item[0]
user.age = item[1]
user.save()
except:
transaction.rollback()
return
transaction.commit()
When I check in database, it has 2 new records. it's not rollback.
Please help me. Thank you very much