diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index c011d9bb0..65e9d512e 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -2603,7 +2603,7 @@ def create( self._defaults["hash_id_columns"] = hash_id_columns if extracts is not None: self._defaults["extracts"] = extracts - if strict: + if strict is not None: self._defaults["strict"] = strict columns = {name: value for (name, value) in columns.items()} diff --git a/tests/test_create.py b/tests/test_create.py index b738df952..14d673064 100644 --- a/tests/test_create.py +++ b/tests/test_create.py @@ -1602,6 +1602,21 @@ def test_create_strict(fresh_db, strict): assert table.strict == strict or not fresh_db.supports_strict +@pytest.mark.parametrize("strict", (False, True)) +def test_create_strict_override_persists(fresh_db, strict): + if not fresh_db.supports_strict: + pytest.skip("SQLite version does not support strict tables") + table = fresh_db.table("t") + table.create({"id": int}, strict=not strict) + assert table.strict is not strict + + table.create({"id": int}, strict=strict, replace=True) + assert table.strict is strict + + table.create({"id": int, "name": str}, replace=True) + assert table.strict is strict + + def test_create_strict_with_any(fresh_db): if not fresh_db.supports_strict: pytest.skip("SQLite version does not support strict tables")