Don't incorrectly detect VIEWs as supporting FTS

sanic-07
Simon Willison 2017-11-24 14:51:00 -08:00
rodzic a81c62d848
commit c5c923d93c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: FBB38AFE227189DB
2 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -287,7 +287,10 @@ def detect_fts_sql(table):
where rootpage = 0
and (
sql like '%VIRTUAL TABLE%USING FTS%content="{table}"%'
or tbl_name = "{table}"
or (
tbl_name = "{table}"
and sql not like 'CREATE VIEW%'
)
)
'''.format(table=table)

Wyświetl plik

@ -143,9 +143,11 @@ def test_detect_fts():
"PlantType" TEXT,
"qCaretaker" TEXT
);
CREATE VIEW Test_View AS SELECT * FROM Dumb_Table;
CREATE VIRTUAL TABLE "Street_Tree_List_fts" USING FTS4 ("qAddress", "qCaretaker", "qSpecies", content="Street_Tree_List");
'''
conn = sqlite3.connect(':memory:')
conn.executescript(sql)
assert None is utils.detect_fts(conn, 'Dumb_Table')
assert None is utils.detect_fts(conn, 'Test_View')
assert 'Street_Tree_List_fts' == utils.detect_fts(conn, 'Street_Tree_List')