This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Inline SQL queries using boolean parameters #15515
Copy link
Copy link
Closed
Labels
O-UncommonMost users are unlikely to come across this or unexpected workflowMost users are unlikely to come across this or unexpected workflowS-TolerableMinor significance, cosmetic issues, low or no impact to users.Minor significance, cosmetic issues, low or no impact to users.T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Z-Help-WantedWe know exactly how to fix this issue, and would be grateful for any contributionWe know exactly how to fix this issue, and would be grateful for any contributiongood first issueGood for newcomersGood for newcomers
Description
Before SQLite 3.23, TRUE
and FALSE
were not recognised as constants by SQLite, and the IS [NOT] TRUE
/IS [NOT] FALSE
operators were not supported. While Synapse supported SQLite versions older 3.23 that made it necessary to avoid using TRUE
and FALSE
constants in SQL commands. To work around this constraint the boolean operators were passed as parameters like so:
synapse/synapse/storage/databases/main/purge_events.py
Lines 251 to 258 in 57aeeb3
txn.execute( | |
"UPDATE events SET outlier = ?" | |
" WHERE event_id IN (" | |
" SELECT event_id FROM events_to_purge " | |
" WHERE NOT should_delete" | |
")", | |
(True,), | |
) |
However, Synapse now requires a SQLite version of 3.27.0 or higher if SQLite is configured so we no longer need to do this and futhermore should convert old-style queries in the codebase to use TRUE
/FALSE
inline as it is easier to parse/read.
Metadata
Metadata
Assignees
Labels
O-UncommonMost users are unlikely to come across this or unexpected workflowMost users are unlikely to come across this or unexpected workflowS-TolerableMinor significance, cosmetic issues, low or no impact to users.Minor significance, cosmetic issues, low or no impact to users.T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Z-Help-WantedWe know exactly how to fix this issue, and would be grateful for any contributionWe know exactly how to fix this issue, and would be grateful for any contributiongood first issueGood for newcomersGood for newcomers