Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite3: fix errors when Drop()ing a SQLite DB containing internal tables #1172

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS autoincr;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE TABLE IF NOT EXISTS autoincr (
id INTEGER PRIMARY KEY AUTOINCREMENT
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- noop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ANALYZE pets;
6 changes: 5 additions & 1 deletion database/sqlite3/sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ func (m *Sqlite) Close() error {
}

func (m *Sqlite) Drop() (err error) {
query := `SELECT name FROM sqlite_master WHERE type = 'table';`
query := `
SELECT name FROM sqlite_master
WHERE type = 'table'
AND name NOT LIKE 'sqlite_%';`

tables, err := m.db.Query(query)
if err != nil {
return &database.Error{OrigErr: err, Query: []byte(query)}
Expand Down
Loading