mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-03 16:04:13 +02:00
Merge 05b5f0fe26 into a947dc6739
This commit is contained in:
commit
de6a4a2e9d
2 changed files with 25 additions and 0 deletions
|
|
@ -880,6 +880,25 @@ def test_transform_with_indexes_errors(fresh_db, transform_params):
|
|||
)
|
||||
|
||||
|
||||
def test_transform_preserves_autoincrement(fresh_db):
|
||||
fresh_db.execute(
|
||||
"CREATE TABLE t (id INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT)"
|
||||
)
|
||||
fresh_db["t"].insert({"val": "one"})
|
||||
fresh_db["t"].insert({"val": "two"})
|
||||
fresh_db["t"].transform(rename={"val": "value"})
|
||||
assert "AUTOINCREMENT" in fresh_db["t"].schema
|
||||
# Confirm the column is still the primary key
|
||||
assert fresh_db["t"].pks == ["id"]
|
||||
|
||||
|
||||
def test_transform_without_autoincrement_not_affected(fresh_db):
|
||||
fresh_db.execute("CREATE TABLE t (id INTEGER PRIMARY KEY, val TEXT)")
|
||||
fresh_db["t"].insert({"val": "one"})
|
||||
fresh_db["t"].transform(rename={"val": "value"})
|
||||
assert "AUTOINCREMENT" not in fresh_db["t"].schema
|
||||
|
||||
|
||||
def test_transform_with_unique_constraint_implicit_index(fresh_db):
|
||||
dogs = fresh_db["dogs"]
|
||||
# Create a table with a UNIQUE constraint on 'name', which creates an implicit index
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue