Skip to content

Commit

Permalink
Fixed bug with detecting FTS tables
Browse files Browse the repository at this point in the history
Closes #135
  • Loading branch information
simonw committed Dec 7, 2017
1 parent 67ad77a commit 709f4f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datasette/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def detect_fts_sql(table):
sql like '%VIRTUAL TABLE%USING FTS%content="{table}"%'
or (
tbl_name = "{table}"
and sql not like 'CREATE VIEW%'
and sql like '%VIRTUAL TABLE%USING FTS%'
)
)
'''.format(table=table)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ def test_detect_fts():
);
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");
CREATE VIRTUAL TABLE r USING rtree(a, b, c);
'''
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 None is utils.detect_fts(conn, 'r')
assert 'Street_Tree_List_fts' == utils.detect_fts(conn, 'Street_Tree_List')


Expand Down

0 comments on commit 709f4f2

Please sign in to comment.