Useful error message for enable_fts() on views, closes #220

This commit is contained in:
Simon Willison 2021-02-14 14:34:22 -08:00
commit ef13bb046f
2 changed files with 13 additions and 0 deletions

View file

@ -2162,6 +2162,11 @@ class View(Queryable):
def drop(self):
self.db.execute("DROP VIEW [{}]".format(self.name))
def enable_fts(self, *args, **kwargs):
raise NotImplementedError(
"enable_fts() is supported on tables but not on views"
)
def chunks(sequence, size):
iterator = iter(sequence)

View file

@ -369,6 +369,14 @@ def test_enable_fts_replace_does_nothing_if_args_the_same():
assert all(q[0].startswith("select ") for q in queries)
def test_enable_fts_error_message_on_views():
db = Database(memory=True)
db.create_view("hello", "select 1 + 1")
with pytest.raises(NotImplementedError) as e:
db["hello"].enable_fts()
assert e.value.args[0] == "enable_fts() is supported on tables but not on views"
@pytest.mark.parametrize(
"kwargs,fts,expected",
[