Skip to content

Commit

Permalink
fix(sqlite): allow using fts5 table name in the where clause
Browse files Browse the repository at this point in the history
  • Loading branch information
naspeh committed Jul 22, 2024
1 parent b78e322 commit d2e447d
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 10 deletions.
8 changes: 5 additions & 3 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.

81 changes: 74 additions & 7 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.

8 changes: 8 additions & 0 deletions internal/endtoend/testdata/virtual_table/sqlite/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ WHERE b = ?;
SELECT c FROM tbl_ft
WHERE b = ?;

-- name: SelectAllColsTblFtEqualByTableName :many
SELECT * FROM tbl_ft
WHERE tbl_ft = ?;

-- name: SelectAllColsTblFtMatchByTableName :many
SELECT * FROM tbl_ft
WHERE tbl_ft MATCH ?;

-- name: SelectHightlighFunc :many
SELECT highlight(tbl_ft, 0, '<b>', '</b>') FROM tbl_ft
WHERE b MATCH ?;
Expand Down
6 changes: 6 additions & 0 deletions internal/engine/sqlite/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ func (c *cc) convertCreate_virtual_table_fts5(n *parser.Create_virtual_table_stm
}
}

stmt.Cols = append(stmt.Cols, &ast.ColumnDef{
Colname: identifier(stmt.Name.Name),
IsNotNull: true,
TypeName: &ast.TypeName{Name: "text"},
})

return stmt
}

Expand Down

0 comments on commit d2e447d

Please sign in to comment.