Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit cdfd871

Browse files
committed
MSC2918: explicit cast on access_tokens.used
Boolean handling seems to be broken with older versions of sqlite making the py3-old environment fail in CI. This explicitely casts the `access_tokens.used` column to INTEGER then compares it with "1" when querying it.
1 parent 908c279 commit cdfd871

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

synapse/storage/databases/main/registration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def _query_for_auth(self, txn, token: str) -> Optional[TokenLookupResult]:
467467
access_tokens.device_id,
468468
access_tokens.valid_until_ms,
469469
access_tokens.user_id as token_owner,
470-
access_tokens.used as token_used
470+
(CAST(access_tokens.used AS INTEGER) = 1) as token_used
471471
FROM users
472472
INNER JOIN access_tokens on users.name = COALESCE(puppets_user_id, access_tokens.user_id)
473473
WHERE token = ?
@@ -1129,7 +1129,7 @@ def _lookup_refresh_token_txn(txn) -> Optional[RefreshTokenLookupResult]:
11291129
rt.device_id,
11301130
rt.next_token_id,
11311131
(nrt.next_token_id IS NOT NULL) has_next_refresh_token_been_refreshed,
1132-
at.used has_next_access_token_been_used
1132+
(CAST(at.used AS INTEGER) = 1) has_next_access_token_been_used
11331133
FROM refresh_tokens rt
11341134
LEFT JOIN refresh_tokens nrt ON rt.next_token_id = nrt.id
11351135
LEFT JOIN access_tokens at ON at.refresh_token_id = nrt.id
@@ -1147,8 +1147,8 @@ def _lookup_refresh_token_txn(txn) -> Optional[RefreshTokenLookupResult]:
11471147
user_id=row[1],
11481148
device_id=row[2],
11491149
next_token_id=row[3],
1150-
has_next_refresh_token_been_refreshed=row[4],
1151-
has_next_access_token_been_used=row[5],
1150+
has_next_refresh_token_been_refreshed=bool(row[4]),
1151+
has_next_access_token_been_used=bool(row[5]),
11521152
)
11531153

11541154
return await self.db_pool.runInteraction(

0 commit comments

Comments
 (0)