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

Commit eb6f8dc

Browse files
authored
Update development docs referencing outdated versions of sqlite we no longer support (#15498)
1 parent 57aeeb3 commit eb6f8dc

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

changelog.d/15498.doc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update outdated development docs that mention restrictions in versions of SQLite that we no longer support.

docs/development/database_schema.md

+1-33
Original file line numberDiff line numberDiff line change
@@ -155,43 +155,11 @@ def run_upgrade(
155155
Boolean columns require special treatment, since SQLite treats booleans the
156156
same as integers.
157157

158-
There are three separate aspects to this:
159-
160-
* Any new boolean column must be added to the `BOOLEAN_COLUMNS` list in
158+
Any new boolean column must be added to the `BOOLEAN_COLUMNS` list in
161159
`synapse/_scripts/synapse_port_db.py`. This tells the port script to cast
162160
the integer value from SQLite to a boolean before writing the value to the
163161
postgres database.
164162

165-
* Before SQLite 3.23, `TRUE` and `FALSE` were not recognised as constants by
166-
SQLite, and the `IS [NOT] TRUE`/`IS [NOT] FALSE` operators were not
167-
supported. This makes it necessary to avoid using `TRUE` and `FALSE`
168-
constants in SQL commands.
169-
170-
For example, to insert a `TRUE` value into the database, write:
171-
172-
```python
173-
txn.execute("INSERT INTO tbl(col) VALUES (?)", (True, ))
174-
```
175-
176-
* Default values for new boolean columns present a particular
177-
difficulty. Generally it is best to create separate schema files for
178-
Postgres and SQLite. For example:
179-
180-
```sql
181-
# in 00delta.sql.postgres:
182-
ALTER TABLE tbl ADD COLUMN col BOOLEAN DEFAULT FALSE;
183-
```
184-
185-
```sql
186-
# in 00delta.sql.sqlite:
187-
ALTER TABLE tbl ADD COLUMN col BOOLEAN DEFAULT 0;
188-
```
189-
190-
Note that there is a particularly insidious failure mode here: the Postgres
191-
flavour will be accepted by SQLite 3.22, but will give a column whose
192-
default value is the **string** `"FALSE"` - which, when cast back to a boolean
193-
in Python, evaluates to `True`.
194-
195163

196164
## `event_id` global uniqueness
197165

0 commit comments

Comments
 (0)