Repository navigation
Conversation
Assisted-by: OpenAI Codex
atishay-kasliwal
left a comment
There was a problem hiding this comment.
With FTS4 and FTS5, detect_fts() now finds the index for a"b, "lead, x%"y and u_"v (master: None). docs, trail" and br]k are unchanged.
| args = { | ||
| "like": f"%VIRTUAL TABLE%USING FTS%content=[{escaped_name}]%", | ||
| "like2": f'%VIRTUAL TABLE%USING FTS%content="{escaped_name}"%', | ||
| "like2": f"%VIRTUAL TABLE%USING FTS%content={quote_identifier(escaped_name)}%", |
There was a problem hiding this comment.
The other direction still matches because of the trailing %. A table a with no FTS, next to a"b with FTS, returns a"b_fts from a.detect_fts(), since content="a"% matches content="a""b". Same for docs next to docs". That happens here and on master, with FTS4 and FTS5. An extra AND sql NOT LIKE '%content="a""%', or comparing the parsed content= value in Python, would close it.
Refs simonw#984 Assisted-by: OpenAI Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #984.
Use
quote_identifier()to match SQLite’s doubled quotes indetect_fts(). Exclude matches where the apparent closing quote is part of an escaped quote, soacannot select the index fora"b, whetherahas its own index or none. Keep legacy bracket quoting and LIKE wildcard escaping.Regression tests cover FTS4 and FTS5, quoted names,
%,_, backslashes, search and index removal. The 24 additional cases from review fail on the preceding PR head and pass with the fix. They verify thatdisable_fts()preserves the neighboring table’s index and triggers. Update the existing tracer test’s expected SQL.Validation on Python 3.12.16 / SQLite 3.53.1: 1,662 passed and 17 skipped in each of the normal and
--sqlite-autocommitruns. Black, flake8, mypy, Pyright, ty, Cog, codespell andgit diff --checkpass.AI assistance: OpenAI Codex helped investigate, implement and test this change.
📚 Documentation preview 📚: https://sqlite-utils--985.org.readthedocs.build/en/985/