Skip to content

Commit c47a2a4

Browse files
committed
Clarifying comments
1 parent e31dbf3 commit c47a2a4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

sqlite_utils/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ def transform_sql(
19691969
)
19701970
# Re-add existing indexes
19711971
for index in self.indexes:
1972-
if index.origin not in ("pk"):
1972+
if index.origin != "pk":
19731973
index_sql = self.db.execute(
19741974
"""SELECT sql FROM sqlite_master WHERE type = 'index' AND name = :index_name;""",
19751975
{"index_name": index.name},

tests/test_transform.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ def test_transform_strict(fresh_db, strict):
551551
],
552552
)
553553
def test_transform_indexes(fresh_db, indexes, transform_params):
554+
# https://github.com/simonw/sqlite-utils/issues/633
555+
# New table should have same indexes as old table after transformation
554556
dogs = fresh_db["dogs"]
555557
dogs.insert({"id": 1, "name": "Cleo", "age": 5, "breed": "Labrador"}, pk="id")
556558

@@ -617,6 +619,7 @@ def test_transform_retains_indexes_with_foreign_keys(fresh_db):
617619
],
618620
)
619621
def test_transform_with_indexes_errors(fresh_db, transform_params):
622+
# Should error with a compound (name, age) index if age is renamed or dropped
620623
dogs = fresh_db["dogs"]
621624
dogs.insert({"id": 1, "name": "Cleo", "age": 5}, pk="id")
622625

0 commit comments

Comments
 (0)