Skip to content

Commit ef13bb0

Browse files
committed
Useful error message for enable_fts() on views, closes #220
1 parent 50d2096 commit ef13bb0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

sqlite_utils/db.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,6 +2162,11 @@ def __repr__(self):
21622162
def drop(self):
21632163
self.db.execute("DROP VIEW [{}]".format(self.name))
21642164

2165+
def enable_fts(self, *args, **kwargs):
2166+
raise NotImplementedError(
2167+
"enable_fts() is supported on tables but not on views"
2168+
)
2169+
21652170

21662171
def chunks(sequence, size):
21672172
iterator = iter(sequence)

tests/test_fts.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,14 @@ def test_enable_fts_replace_does_nothing_if_args_the_same():
369369
assert all(q[0].startswith("select ") for q in queries)
370370

371371

372+
def test_enable_fts_error_message_on_views():
373+
db = Database(memory=True)
374+
db.create_view("hello", "select 1 + 1")
375+
with pytest.raises(NotImplementedError) as e:
376+
db["hello"].enable_fts()
377+
assert e.value.args[0] == "enable_fts() is supported on tables but not on views"
378+
379+
372380
@pytest.mark.parametrize(
373381
"kwargs,fts,expected",
374382
[

0 commit comments

Comments
 (0)