mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 17:34:32 +02:00
table.create(..., replace=True / ignore = True) closes #568
This commit is contained in:
parent
b379a2a0c3
commit
58b577279f
3 changed files with 38 additions and 7 deletions
|
|
@ -1186,6 +1186,25 @@ def test_create_if_no_columns(fresh_db):
|
|||
assert error.value.args[0] == "Tables must have at least one column"
|
||||
|
||||
|
||||
def test_create_ignore(fresh_db):
|
||||
fresh_db["t"].create({"id": int})
|
||||
# This should error
|
||||
with pytest.raises(sqlite3.OperationalError):
|
||||
fresh_db["t"].create({"id": int})
|
||||
# This should not
|
||||
fresh_db["t"].create({"id": int}, ignore=True)
|
||||
|
||||
|
||||
def test_create_replace(fresh_db):
|
||||
fresh_db["t"].create({"id": int})
|
||||
# This should error
|
||||
with pytest.raises(sqlite3.OperationalError):
|
||||
fresh_db["t"].create({"id": int})
|
||||
# This should not
|
||||
fresh_db["t"].create({"name": str}, replace=True)
|
||||
assert fresh_db["t"].schema == ("CREATE TABLE [t] (\n" " [name] TEXT\n" ")")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"cols,kwargs,expected_schema,should_transform",
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue