fix: scope transactional locks to primary records
This commit is contained in:
@@ -493,7 +493,11 @@ def update_ticket_fields(
|
||||
if unknown_fields:
|
||||
raise TicketDataError(f"不允许修改字段: {', '.join(sorted(unknown_fields))}")
|
||||
|
||||
ticket = Ticket.objects.select_for_update().select_related("category").get(id=ticket.id)
|
||||
ticket = (
|
||||
Ticket.objects.select_for_update(of=("self",))
|
||||
.select_related("category")
|
||||
.get(id=ticket.id)
|
||||
)
|
||||
evidence_by_field = evidence_by_field or {}
|
||||
confidence_by_field = confidence_by_field or {}
|
||||
before: dict = {}
|
||||
@@ -841,7 +845,7 @@ def adopt_solution_for_ticket(
|
||||
if locked_solution.status != "published":
|
||||
raise TicketDataError("只能采纳已发布的解决方案")
|
||||
locked_ticket = (
|
||||
Ticket.objects.select_for_update()
|
||||
Ticket.objects.select_for_update(of=("self",))
|
||||
.select_related("category", "resolution")
|
||||
.get(id=ticket.id)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user