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