Skip to content

Commit e8788d9

Browse files
committed
sqlite3: fix error when dropping db with sqlite_sequence table
If column declaration uses `AUTOINCREMENT` keyword, a new column is created into table `sqlite_sequence` which can not be dropped. Currently, `sqlite3.Drop()` resolves tables to be dropped by querying table `sqlite_master` for all tables in the database. However, this query also returns aforementioned `sqlite_sequence` table. This commit adds a filter to the query resolving tables to be dropped. Filter removes `sqlite_sequence` from the query results.
1 parent 4f3c203 commit e8788d9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

database/sqlite3/sqlite3.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ func (m *Sqlite) Close() error {
134134
}
135135

136136
func (m *Sqlite) Drop() (err error) {
137-
query := `SELECT name FROM sqlite_master WHERE type = 'table';`
137+
query := `
138+
SELECT name FROM sqlite_master
139+
WHERE type = 'table'
140+
AND name NOT IN (
141+
'sqlite_sequence'
142+
);`
143+
138144
tables, err := m.db.Query(query)
139145
if err != nil {
140146
return &database.Error{OrigErr: err, Query: []byte(query)}

0 commit comments

Comments
 (0)