Skip to content

Commit a4bbafc

Browse files
committed
fix(sqlite): allow using fts5 table name in the where clause
1 parent 60f1b88 commit a4bbafc

File tree

4 files changed

+93
-10
lines changed

4 files changed

+93
-10
lines changed

internal/endtoend/testdata/virtual_table/sqlite/go/models.go

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/virtual_table/sqlite/go/query.sql.go

+74-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/virtual_table/sqlite/query.sql

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ WHERE b = ?;
1414
SELECT c FROM tbl_ft
1515
WHERE b = ?;
1616

17+
-- name: SelectAllColsTblFtEqualByTableName :many
18+
SELECT * FROM tbl_ft
19+
WHERE tbl_ft = ?;
20+
21+
-- name: SelectAllColsTblFtMatchByTableName :many
22+
SELECT * FROM tbl_ft
23+
WHERE tbl_ft MATCH ?;
24+
1725
-- name: SelectHightlighFunc :many
1826
SELECT highlight(tbl_ft, 0, '<b>', '</b>') FROM tbl_ft
1927
WHERE b MATCH ?;

internal/engine/sqlite/convert.go

+6
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ func (c *cc) convertCreate_virtual_table_fts5(n *parser.Create_virtual_table_stm
168168
}
169169
}
170170

171+
stmt.Cols = append(stmt.Cols, &ast.ColumnDef{
172+
Colname: identifier(stmt.Name.Name),
173+
IsNotNull: true,
174+
TypeName: &ast.TypeName{Name: "text"},
175+
})
176+
171177
return stmt
172178
}
173179

0 commit comments

Comments
 (0)