mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-12 11:34:09 +02:00
.enable_fts() now works with columns with spaces in them, closes #90
This commit is contained in:
parent
2ac4ea3c95
commit
0c36feb6ca
2 changed files with 15 additions and 1 deletions
|
|
@ -785,7 +785,7 @@ class Table(Queryable):
|
||||||
INSERT INTO [{table}_fts] (rowid, {columns})
|
INSERT INTO [{table}_fts] (rowid, {columns})
|
||||||
SELECT rowid, {columns} FROM [{table}];
|
SELECT rowid, {columns} FROM [{table}];
|
||||||
""".format(
|
""".format(
|
||||||
table=self.name, columns=", ".join(columns)
|
table=self.name, columns=", ".join("[{}]".format(c) for c in columns)
|
||||||
)
|
)
|
||||||
self.db.conn.executescript(sql)
|
self.db.conn.executescript(sql)
|
||||||
return self
|
return self
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,20 @@ def test_enable_fts_escape_table_names(fresh_db):
|
||||||
assert [] == table.search("bar")
|
assert [] == table.search("bar")
|
||||||
|
|
||||||
|
|
||||||
|
def test_enable_fts_table_names_containing_spaces(fresh_db):
|
||||||
|
table = fresh_db["test"]
|
||||||
|
table.insert({"column with spaces": "in its name"})
|
||||||
|
table.enable_fts(["column with spaces"])
|
||||||
|
assert [
|
||||||
|
"test",
|
||||||
|
"test_fts",
|
||||||
|
"test_fts_data",
|
||||||
|
"test_fts_idx",
|
||||||
|
"test_fts_docsize",
|
||||||
|
"test_fts_config",
|
||||||
|
] == fresh_db.table_names()
|
||||||
|
|
||||||
|
|
||||||
def test_populate_fts(fresh_db):
|
def test_populate_fts(fresh_db):
|
||||||
table = fresh_db["populatable"]
|
table = fresh_db["populatable"]
|
||||||
table.insert(search_records[0])
|
table.insert(search_records[0])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue