Skip to content

feat(sqlite): virtual tables and fts5 supported #2531

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

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions internal/endtoend/testdata/virtual_table/sqlite/go/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions internal/endtoend/testdata/virtual_table/sqlite/go/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

248 changes: 248 additions & 0 deletions internal/endtoend/testdata/virtual_table/sqlite/go/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions internal/endtoend/testdata/virtual_table/sqlite/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- name: SelectAllColsFt :many
SELECT b FROM ft
WHERE b MATCH ?;

-- name: SelectAllColsTblFt :many
SELECT b, c FROM tbl_ft
WHERE b MATCH ?;

-- name: SelectOneColFt :many
SELECT b FROM ft
WHERE b = ?;

-- name: SelectOneColTblFt :many
SELECT c FROM tbl_ft
WHERE b = ?;

-- name: SelectHightlighFunc :many
SELECT highlight(tbl_ft, 0, '<b>', '</b>') FROM tbl_ft
WHERE b MATCH ?;

-- name: SelectSnippetFunc :many
SELECT snippet(tbl_ft, 0, '<b>', '</b>', 'aa', ?) FROM tbl_ft;

-- name: SelectBm25Func :many
SELECT *, bm25(tbl_ft, 2.0) FROM tbl_ft
WHERE b MATCH ? ORDER BY bm25(tbl_ft);

-- name: UpdateTblFt :exec
UPDATE tbl_ft SET c = ? WHERE b = ?;

-- name: DeleteTblFt :exec
DELETE FROM tbl_ft WHERE b = ?;

-- name: InsertTblFt :exec
INSERT INTO tbl_ft(b, c) VALUES(?, ?);
15 changes: 15 additions & 0 deletions internal/endtoend/testdata/virtual_table/sqlite/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE tbl(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d TEXT, e INTEGER);

CREATE VIRTUAL TABLE tbl_ft USING fts5(b, c UNINDEXED, content='tbl', content_rowid='a');

CREATE VIRTUAL TABLE ft USING fts5(b);

CREATE TRIGGER tbl_ai AFTER INSERT ON tbl BEGIN
INSERT INTO tbl_ft(rowid, b, c) VALUES (new.a, new.b, new.c);
END;

INSERT INTO tbl VALUES(1, 'xx yy cc', 't', 'a', 11);
INSERT INTO tbl VALUES(2, 'aa bb', 't', 'a', 22);

INSERT INTO ft VALUES('xx cc');
INSERT INTO ft VALUES('cc bb');
9 changes: 9 additions & 0 deletions internal/endtoend/testdata/virtual_table/sqlite/sqlc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '2'
sql:
- schema: schema.sql
queries: query.sql
engine: sqlite
gen:
go:
package: querytest
out: go
Loading