mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-27 03:14:33 +02:00
not_null support for .create(transform=True), refs #467
This commit is contained in:
parent
9e3d8abc58
commit
341f000097
2 changed files with 14 additions and 2 deletions
|
|
@ -1197,6 +1197,13 @@ def test_create_if_no_columns(fresh_db):
|
|||
"CREATE TABLE [demo] (\n [id] INTEGER PRIMARY KEY,\n [name] TEXT\n)",
|
||||
False,
|
||||
),
|
||||
# Change not null
|
||||
(
|
||||
{"id": int, "name": str},
|
||||
{"pk": "id", "not_null": {"name"}},
|
||||
'CREATE TABLE "demo" (\n [id] INTEGER PRIMARY KEY,\n [name] TEXT NOT NULL\n)',
|
||||
True,
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_create_transform(fresh_db, cols, kwargs, expected_schema, should_transform):
|
||||
|
|
@ -1205,8 +1212,8 @@ def test_create_transform(fresh_db, cols, kwargs, expected_schema, should_transf
|
|||
traces = []
|
||||
with fresh_db.tracer(lambda sql, parameters: traces.append((sql, parameters))):
|
||||
fresh_db["demo"].create(cols, **kwargs, transform=True)
|
||||
new_schema = fresh_db["demo"].schema
|
||||
assert new_schema == expected_schema, repr(new_schema)
|
||||
at_least_one_create_table = any(sql.startswith("CREATE TABLE") for sql, _ in traces)
|
||||
assert should_transform == at_least_one_create_table
|
||||
new_schema = fresh_db["demo"].schema
|
||||
assert new_schema == expected_schema, repr(new_schema)
|
||||
assert fresh_db["demo"].count == 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue