Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FTS5 support to sqlite #1797

Closed
kkyr opened this issue Aug 14, 2022 · 4 comments · Fixed by #2531
Closed

Add FTS5 support to sqlite #1797

kkyr opened this issue Aug 14, 2022 · 4 comments · Fixed by #2531
Labels

Comments

@kkyr
Copy link

kkyr commented Aug 14, 2022

What do you want to change?

Add FTS5 support to sqlite engine.

schema.sql

CREATE TABLE recipes (
    id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
);

CREATE VIRTUAL TABLE recipes_fts USING FTS5 (
    name,
    content='recipes',
    content_rowid='id'
);

-- (triggers omitted)

query.sql

-- name: SearchRecipes :many
SELECT rowid, * FROM recipes_fts
WHERE recipes_fts MATCH ?;

Running sqlc generate on the above input results in the following error:

db/sqlite/query.sql:17:1: relation "recipes_fts" does not exist

What database engines need to be changed?

sqlite

What programming language backends need to be changed?

Go

@kkyr kkyr added enhancement New feature or request triage New issues that hasn't been reviewed labels Aug 14, 2022
@kkyr kkyr changed the title Add sqlite support for FTS5 Add FTS5 support to sqlite Aug 14, 2022
@kyleconroy kyleconroy added 📚 sqlite accepted and removed triage New issues that hasn't been reviewed labels Aug 20, 2022
@lvignoli
Copy link

Hello!
Any plan to implement this feature? :)

mcdoker18 added a commit to mcdoker18/sqlc that referenced this issue Jul 26, 2023
Fixes: sqlc-dev#1797

Out of scope:
* table-valued function. https://www.sqlite.org/vtab.html#tabfunc2
* insert commands. https://www.sqlite.org/fts5.html#special_insert_commands
* you cannot use table name to the left of MATCH or equality operator
mcdoker18 added a commit to mcdoker18/sqlc that referenced this issue Jul 26, 2023
Fixes: sqlc-dev#1797

Out of scope:
* table-valued function. https://www.sqlite.org/vtab.html#tabfunc2
* insert commands. https://www.sqlite.org/fts5.html#special_insert_commands
* you cannot use table name to the left of MATCH or equality operator
kyleconroy pushed a commit that referenced this issue Jul 26, 2023
Fixes: #1797

Out of scope:
* table-valued function. https://www.sqlite.org/vtab.html#tabfunc2
* insert commands. https://www.sqlite.org/fts5.html#special_insert_commands
* you cannot use table name to the left of MATCH or equality operator
@lvignoli
Copy link

🎉🎉🎉
Thanks !

@yanc0
Copy link

yanc0 commented Dec 5, 2023

@mcdoker18 @lvignoli I can't figure out how to use this.

SELECT *
FROM documents
WHERE id IN (
    SELECT document_id as id FROM documents_fts
    WHERE documents_fts MATCH ?
    ORDER BY rank
)
LIMIT ?
OFFSET ?;

queries.sql:6:11: column "documents_fts" does not exist

I want MATCH on every columns of the virtual fts5 table. I can't find a way to do this.

@mcdoker18
Copy link
Contributor

@yanc0 Hi, sorry for the late response. This was not implemented in my commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants