mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Fix for detect_fts failing on [], refs #694
This commit is contained in:
parent
6729ea3f60
commit
1a28416e10
2 changed files with 24 additions and 1 deletions
|
|
@ -2776,7 +2776,7 @@ class Table(Queryable):
|
|||
)
|
||||
""").strip()
|
||||
args = {
|
||||
"like": '%VIRTUAL TABLE%USING FTS%content="{}"%'.format(self.name),
|
||||
"like": "%VIRTUAL TABLE%USING FTS%content=[{}]%".format(self.name),
|
||||
"like2": '%VIRTUAL TABLE%USING FTS%content="{}"%'.format(self.name),
|
||||
"table": self.name,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,6 +420,29 @@ 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_replace_handles_legacy_bracket_quoted_content_table():
|
||||
db = Database(memory=True)
|
||||
db["books"].insert(
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Habits of Australian Marsupials",
|
||||
"author": "Marlee Hawkins",
|
||||
},
|
||||
pk="id",
|
||||
)
|
||||
db.executescript("""
|
||||
CREATE VIRTUAL TABLE [books_fts] USING FTS5 (
|
||||
[title],
|
||||
content=[books]
|
||||
);
|
||||
""")
|
||||
|
||||
db["books"].enable_fts(["title", "author"], replace=True)
|
||||
|
||||
assert db["books_fts"].columns_dict.keys() == {"title", "author"}
|
||||
assert 'content="books"' in db["books_fts"].schema
|
||||
|
||||
|
||||
def test_enable_fts_error_message_on_views():
|
||||
db = Database(memory=True)
|
||||
db.create_view("hello", "select 1 + 1")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue