Skip to content

Commit

Permalink
Fix test error - Save with update_fields did not affect any rows.
Browse files Browse the repository at this point in the history
Related to #2951

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/OWASP-BLT/BLT/issues/2951?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
DonnieBLT committed Nov 19, 2024
1 parent d7d0c31 commit 5b45487
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion blt/middleware/ip_restrict.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def __call__(self, request):
ip_record.agent = agent
ip_record.count = new_count
ip_record.path = request.path
ip_record.save(update_fields=["agent", "count", "path"])
if ip_record.pk:
ip_record.save(update_fields=["agent", "count", "path"])

# Check if a transaction is already active before starting a new one
if not transaction.get_autocommit():
Expand Down

0 comments on commit 5b45487

Please sign in to comment.