mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fixed bug with detect_fts for table with single quote in name, closes #1257
This commit is contained in:
parent
807de378d0
commit
0f1e47287c
2 changed files with 17 additions and 1 deletions
|
|
@ -547,7 +547,7 @@ def detect_fts_sql(table):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
""".format(
|
""".format(
|
||||||
table=table
|
table=table.replace("'", "''")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,22 @@ def test_detect_fts(open_quote, close_quote):
|
||||||
assert "Street_Tree_List_fts" == utils.detect_fts(conn, "Street_Tree_List")
|
assert "Street_Tree_List_fts" == utils.detect_fts(conn, "Street_Tree_List")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("table", ("regular", "has'single quote"))
|
||||||
|
def test_detect_fts_different_table_names(table):
|
||||||
|
sql = """
|
||||||
|
CREATE TABLE [{table}] (
|
||||||
|
"TreeID" INTEGER,
|
||||||
|
"qSpecies" TEXT
|
||||||
|
);
|
||||||
|
CREATE VIRTUAL TABLE [{table}_fts] USING FTS4 ("qSpecies", content="{table}");
|
||||||
|
""".format(
|
||||||
|
table=table
|
||||||
|
)
|
||||||
|
conn = utils.sqlite3.connect(":memory:")
|
||||||
|
conn.executescript(sql)
|
||||||
|
assert "{table}_fts".format(table=table) == utils.detect_fts(conn, table)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"url,expected",
|
"url,expected",
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue