html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,issue,performed_via_github_app https://github.com/simonw/sqlite-utils/issues/434#issuecomment-1155801812,https://api.github.com/repos/simonw/sqlite-utils/issues/434,1155801812,IC_kwDOCGYnMM5E5CLU,9599,2022-06-14T23:23:32Z,2022-06-14T23:23:32Z,OWNER,"Since table names can be quoted like this: ```sql CREATE VIRTUAL TABLE ""searchable_fts"" USING FTS4 (text1, text2, [name with . and spaces], content=""searchable"") ``` OR like this: ```sql CREATE VIRTUAL TABLE ""searchable_fts"" USING FTS4 (text1, text2, [name with . and spaces], content=[searchable]) ``` This fix looks to be correct to me (copying from the updated `test_with_trace()` test): ```python ( ""SELECT name FROM sqlite_master\n"" "" WHERE rootpage = 0\n"" "" AND (\n"" "" sql LIKE :like\n"" "" OR sql LIKE :like2\n"" "" OR (\n"" "" tbl_name = :table\n"" "" AND sql LIKE '%VIRTUAL TABLE%USING FTS%'\n"" "" )\n"" "" )"", { ""like"": ""%VIRTUAL TABLE%USING FTS%content=[dogs]%"", ""like2"": '%VIRTUAL TABLE%USING FTS%content=""dogs""%', ""table"": ""dogs"", }, ) ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1243151184, https://github.com/simonw/sqlite-utils/issues/434#issuecomment-1155794149,https://api.github.com/repos/simonw/sqlite-utils/issues/434,1155794149,IC_kwDOCGYnMM5E5ATl,9599,2022-06-14T23:09:54Z,2022-06-14T23:09:54Z,OWNER,"A test that demonstrates the problem: ```python @pytest.mark.parametrize(""reverse_order"", (True, False)) def test_detect_fts_similar_tables(fresh_db, reverse_order): # https://github.com/simonw/sqlite-utils/issues/434 table1, table2 = (""demo"", ""demo2"") if reverse_order: table1, table2 = table2, table1 fresh_db[table1].insert({""title"": ""Hello""}).enable_fts( [""title""], fts_version=""FTS4"" ) fresh_db[table2].insert({""title"": ""Hello""}).enable_fts( [""title""], fts_version=""FTS4"" ) assert fresh_db[table1].detect_fts() == ""{}_fts"".format(table1) assert fresh_db[table2].detect_fts() == ""{}_fts"".format(table2) ``` The order matters - so this test currently passes in one direction and fails in the other: ``` > assert fresh_db[table2].detect_fts() == ""{}_fts"".format(table2) E AssertionError: assert 'demo2_fts' == 'demo_fts' E - demo_fts E + demo2_fts E ? + tests/test_introspect.py:53: AssertionError ========================================================================================= short test summary info ========================================================================================= FAILED tests/test_introspect.py::test_detect_fts_similar_tables[True] - AssertionError: assert 'demo2_fts' == 'demo_fts' =============================================================================== 1 failed, 1 passed, 855 deselected in 1.00s =============================================================================== ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1243151184, https://github.com/simonw/sqlite-utils/issues/434#issuecomment-1155791109,https://api.github.com/repos/simonw/sqlite-utils/issues/434,1155791109,IC_kwDOCGYnMM5E4_kF,9599,2022-06-14T23:04:40Z,2022-06-14T23:04:40Z,OWNER,"Definitely a bug - thanks for the detailed write-up! You're right, the code at fault is here: https://github.com/simonw/sqlite-utils/blob/1b09538bc6c1fda773590f3e600993ef06591041/sqlite_utils/db.py#L2213-L2231","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1243151184,