Skip to content

Commit 459d510

Browse files
committed
Add tests for previously-requested SQLite flags
* astral-sh#309: -DSQLITE_ENABLE_DBSTAT_VTAB * astral-sh#449: serialize/deserialize (on by default, was just a compile-time detection issue) * astral-sh#550/astral-sh#562: -DSQLITE_ENABLE_FTS3_PARENTHESIS and -DSQLITE_ENABLE_FTS3_TOKENIZER
1 parent 0fa18ac commit 459d510

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/verify_distribution.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,33 @@ def test_sqlite(self):
137137
cursor.execute(
138138
f"CREATE VIRTUAL TABLE test{extension} USING {extension}(a, b, c);"
139139
)
140+
141+
# Test various SQLite flags and features requested / expected by users.
142+
# The DBSTAT virtual table shows some metadata about disk usage.
143+
# https://www.sqlite.org/dbstat.html
144+
self.assertNotEqual(
145+
cursor.execute("SELECT COUNT(*) FROM dbstat;").fetchone()[0],
146+
0,
147+
)
148+
149+
# The serialize/deserialize API is configurable at compile time.
150+
self.assertEqual(conn.serialize()[:15], b"SQLite format 3")
151+
152+
# The "enhanced query syntax" (-DSQLITE_ENABLE_FTS3_PARENTHESIS) allows parenthesizable
153+
# AND, OR, and NOT operations. The "standard query syntax" only has OR as a keyword, so we
154+
# can test for the difference with a query using AND.
155+
# https://www.sqlite.org/fts3.html#_set_operations_using_the_enhanced_query_syntax
156+
cursor.execute("INSERT INTO testfts3 VALUES('hello world');")
157+
self.assertEqual(
158+
cursor.execute("SELECT COUNT(*) FROM testfts3 WHERE a MATCH 'hello AND world';").fetchone()[0],
159+
1,
160+
)
161+
162+
# Allow user-defined tokenizers by default... though arguably this should be off by default
163+
# since applications that need it can turn it on, see discussion at
164+
# https://github.com/astral-sh/python-build-standalone/pull/562#issuecomment-3254522958
165+
self.assertTrue(conn.getconfig(sqlite3.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER))
166+
140167
conn.close()
141168

142169
def test_ssl(self):

0 commit comments

Comments
 (0)