Skip to content

Commit 6d95887

Browse files
committed
Add rowid column to FTS5 tables
1 parent b2933a8 commit 6d95887

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

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

Lines changed: 5 additions & 3 deletions
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

Lines changed: 31 additions & 8 deletions
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
-- name: SelectRowID :one
2+
SELECT rowid FROM ft
3+
LIMIT 1;
4+
15
-- name: SelectAllColsFt :many
26
SELECT b FROM ft
37
WHERE b MATCH ?;

internal/engine/sqlite/convert.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ func (c *cc) convertCreate_virtual_table_fts5(n *parser.Create_virtual_table_stm
146146
IfNotExists: n.EXISTS_() != nil,
147147
}
148148

149+
// All FTS5 virtual tables implicitly contain a 'rowid' column.
150+
stmt.Cols = append(stmt.Cols, &ast.ColumnDef{
151+
Colname: "rowid",
152+
IsNotNull: true,
153+
TypeName: &ast.TypeName{Name: "integer"},
154+
})
155+
149156
for _, arg := range n.AllModule_argument() {
150157
var columnName string
151158

0 commit comments

Comments
 (0)