Skip to content
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
2 changes: 1 addition & 1 deletion sqlite_utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down
15 changes: 15 additions & 0 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading