Skip to content

Commit 08812ba

Browse files
committed
fix(sqlite): register fts5 and rtree extensions explicitly
go-sqlite3 v0.35.0 moved the FTS5 and R*Tree/Geopoly extensions into separate packages, so they are no longer part of the default build. This broke schemas that use virtual tables, e.g. CREATE VIRTUAL TABLE ft USING fts5(b); which now fails with "no such module: fts5" when the SQLite analyzer applies migrations. Add an internal package that registers both extensions as auto extensions, and import it wherever sqlc opens a SQLite connection, so they are available on every connection as they were before the bump. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011B9zXEdnMfRMVmWQaJFXVS
1 parent 8a62603 commit 08812ba

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

internal/cmd/vet_sqlite.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ package cmd
22

33
import (
44
_ "github.com/ncruces/go-sqlite3/driver"
5+
6+
_ "github.com/sqlc-dev/sqlc/internal/sqlite3ext"
57
)

internal/engine/sqlite/analyzer/analyze.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/sqlc-dev/sqlc/internal/sql/named"
1717
"github.com/sqlc-dev/sqlc/internal/sql/sqlerr"
1818
"github.com/sqlc-dev/sqlc/internal/sqlcdebug"
19+
_ "github.com/sqlc-dev/sqlc/internal/sqlite3ext"
1920
)
2021

2122
var debugDatabases = sqlcdebug.New("databases")

internal/sqlite3ext/sqlite3ext.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Package sqlite3ext registers the SQLite extensions sqlc relies on with
2+
// github.com/ncruces/go-sqlite3.
3+
//
4+
// As of go-sqlite3 v0.35.0 the FTS5 and R*Tree/Geopoly extensions are compiled
5+
// separately and are no longer part of the default build. Registering them as
6+
// auto extensions makes them available on every connection, matching the
7+
// behavior of earlier releases.
8+
//
9+
// Import this package for side effects wherever a SQLite connection is opened.
10+
package sqlite3ext
11+
12+
import (
13+
"github.com/ncruces/go-sqlite3"
14+
"github.com/ncruces/go-sqlite3/ext/fts5"
15+
"github.com/ncruces/go-sqlite3/ext/rtree"
16+
)
17+
18+
func init() {
19+
sqlite3.AutoExtension(fts5.Register)
20+
sqlite3.AutoExtension(rtree.Register)
21+
}

internal/sqltest/sqlite.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
_ "github.com/ncruces/go-sqlite3/driver"
1010

1111
"github.com/sqlc-dev/sqlc/internal/sql/sqlpath"
12+
_ "github.com/sqlc-dev/sqlc/internal/sqlite3ext"
1213
)
1314

1415
func SQLite(t *testing.T, migrations []string) (*sql.DB, func()) {

0 commit comments

Comments
 (0)