mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-31 06:24:21 +02:00
parent
0fe3b38290
commit
e8f887ef4a
6 changed files with 64 additions and 0 deletions
|
|
@ -310,6 +310,16 @@ def test_add_column_foreign_key(db_path):
|
|||
assert "table 'bobcats' does not exist" in str(result.exception)
|
||||
|
||||
|
||||
def test_index_foreign_keys(db_path):
|
||||
test_add_column_foreign_key(db_path)
|
||||
db = Database(db_path)
|
||||
assert [] == db["books"].indexes
|
||||
result = CliRunner().invoke(cli.cli, ["index-foreign-keys", db_path])
|
||||
assert [["author_id"], ["author_name_ref"]] == [
|
||||
i.columns for i in db["books"].indexes
|
||||
]
|
||||
|
||||
|
||||
def test_enable_fts(db_path):
|
||||
assert None == Database(db_path)["Gosh"].detect_fts()
|
||||
result = CliRunner().invoke(
|
||||
|
|
|
|||
|
|
@ -361,6 +361,16 @@ def test_add_foreign_key_guess_table(fresh_db):
|
|||
)
|
||||
|
||||
|
||||
def test_index_foreign_keys(fresh_db):
|
||||
test_add_foreign_key_guess_table(fresh_db)
|
||||
assert [] == fresh_db["dogs"].indexes
|
||||
fresh_db.index_foreign_keys()
|
||||
assert [["breed_id"]] == [i.columns for i in fresh_db["dogs"].indexes]
|
||||
# Calling it a second time should do nothing
|
||||
fresh_db.index_foreign_keys()
|
||||
assert [["breed_id"]] == [i.columns for i in fresh_db["dogs"].indexes]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"extra_data,expected_new_columns",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue