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

Commits on Sep 20, 2024

  1. sqlite3/examples: add migration with table w/ AUTOINCREMENT

    Declaring column as `AUTOINCREMENT` causes SQLite to create a new table
    `sqlite_sequence` under the hood, which cannot be dropped. This is
    useful in `migration.Drop()` tests.
    hofnarrr committed Sep 20, 2024
    Configuration menu
    Copy the full SHA
    4f3c203 View commit details
    Browse the repository at this point in the history
  2. sqlite3/examples: add migration running ANALYZE

    Running `ANALYZE` causes SQLite to create internal undroppable tables.
    This is useful during `migrate.Drop()` testing.
    hofnarrr committed Sep 20, 2024
    Configuration menu
    Copy the full SHA
    2668b50 View commit details
    Browse the repository at this point in the history
  3. sqlite3: fix error when dropping db with system tables

    In some cases SQLite creates new tables for internal use. The names
    of these internal schema objects[0] always begin with `sqlite_` and are
    not to be touched by applications.
    
    Example case: 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 tables starting with `sqlite_` from the query results.
    
    [0]: https://www.sqlite.org/fileformat2.html#intschema
    hofnarrr committed Sep 20, 2024
    Configuration menu
    Copy the full SHA
    edd80e2 View commit details
    Browse the repository at this point in the history