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

Inline SQL queries using boolean parameters #15515

@H-Shay

Description

@H-Shay

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:

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

No one assigned

    Labels

    O-UncommonMost users are unlikely to come across this or unexpected workflowS-TolerableMinor significance, cosmetic issues, low or no impact to users.T-TaskRefactoring, 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 contributiongood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions