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

Documentation should recommend testing with pragma legacy_alter_table=on #7

Open
simonw opened this issue Aug 19, 2023 · 2 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@simonw
Copy link
Owner

simonw commented Aug 19, 2023

See here:

@simonw simonw changed the title Documentation should recommend testing with Documentation should recommend testing with pragma legacy_alter_table=on Aug 19, 2023
@simonw simonw added the documentation Improvements or additions to documentation label Aug 19, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 19, 2023

The resolution of this bug was protected by this test:

def test_migrations_with_legacy_alter_table():
    db = sqlite_utils.Database(memory=True)
    db.execute("pragma legacy_alter_table=on")
    migrate(db)

When I write testing documentation for this package I should include that as a recommendation - or maybe even suggest a pattern like this:

@pytest.mark.parametrize("legacy_alter_table", (True, False))
def test_migrations_with_legacy_alter_table(legacy_alter_table):
    db = sqlite_utils.Database(memory=True)
    db.execute("pragma legacy_alter_table={}".format("on" if legacy_alter_table else "off"))
    migrate(db)

@simonw
Copy link
Owner Author

simonw commented Aug 19, 2023

Another pattern that could work here: build a sqlite-utils plugin that turns that mode on for all connections, then show people how to use a GitHub Actions matrix build to run their tests twice, once with and once without that plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant