Skip to content

Commit

Permalink
Fix select for update (#906)
Browse files Browse the repository at this point in the history
* removed limit on select for update (due to an Oracle 12c limitation)

* added my name to authors

* Use filter and wrap in a list

* documentation
  • Loading branch information
dag18e committed Feb 7, 2021
1 parent 3010059 commit 331b49d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ Jun Zhou
David Smith
Łukasz Skarżyński
Tom Evans
Dylan Giesler
Spencer Carroll
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
* #884 Added support for Python 3.9

### Fixed
* made token revocation not apply a limit to the `select_for_update` statement #866

## [1.3.3] 2020-10-16

### Added
Expand Down
14 changes: 8 additions & 6 deletions oauth2_provider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,15 @@ def revoke(self):
access_token_model = get_access_token_model()
refresh_token_model = get_refresh_token_model()
with transaction.atomic():
self = (
refresh_token_model.objects.filter(pk=self.pk, revoked__isnull=True)
.select_for_update()
.first()
)
if not self:
try:
token = refresh_token_model.objects.select_for_update().filter(
pk=self.pk, revoked__isnull=True
)
except refresh_token_model.DoesNotExist:
return
if not token:
return
self = list(token)[0]

try:
access_token_model.objects.get(id=self.access_token_id).revoke()
Expand Down

0 comments on commit 331b49d

Please sign in to comment.