mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-10 02:24:22 +02:00
Add --ignore to create-index as alias of --if-not-exists, refs #450
This commit is contained in:
parent
40b6947255
commit
2c77f4467e
3 changed files with 13 additions and 13 deletions
|
|
@ -841,12 +841,12 @@ See :ref:`cli_create_index`.
|
||||||
sqlite-utils create-index chickens.db chickens -- -name
|
sqlite-utils create-index chickens.db chickens -- -name
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--name TEXT Explicit name for the new index
|
--name TEXT Explicit name for the new index
|
||||||
--unique Make this a unique index
|
--unique Make this a unique index
|
||||||
--if-not-exists Ignore if index already exists
|
--if-not-exists, --ignore Ignore if index already exists
|
||||||
--analyze Run ANALYZE after creating the index
|
--analyze Run ANALYZE after creating the index
|
||||||
--load-extension TEXT SQLite extensions to load
|
--load-extension TEXT SQLite extensions to load
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
|
|
||||||
|
|
||||||
enable-fts
|
enable-fts
|
||||||
|
|
|
||||||
|
|
@ -539,6 +539,7 @@ def index_foreign_keys(path, load_extension):
|
||||||
@click.option("--unique", help="Make this a unique index", default=False, is_flag=True)
|
@click.option("--unique", help="Make this a unique index", default=False, is_flag=True)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--if-not-exists",
|
"--if-not-exists",
|
||||||
|
"--ignore",
|
||||||
help="Ignore if index already exists",
|
help="Ignore if index already exists",
|
||||||
default=False,
|
default=False,
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
|
|
|
||||||
|
|
@ -214,13 +214,12 @@ def test_create_index(db_path):
|
||||||
] == db["Gosh2"].indexes
|
] == db["Gosh2"].indexes
|
||||||
# Trying to create the same index should fail
|
# Trying to create the same index should fail
|
||||||
assert 0 != CliRunner().invoke(cli.cli, create_index_unique_args).exit_code
|
assert 0 != CliRunner().invoke(cli.cli, create_index_unique_args).exit_code
|
||||||
# ... unless we use --if-not-exists
|
# ... unless we use --if-not-exists or --ignore
|
||||||
assert (
|
for option in ("--if-not-exists", "--ignore"):
|
||||||
0
|
assert (
|
||||||
== CliRunner()
|
CliRunner().invoke(cli.cli, create_index_unique_args + [option]).exit_code
|
||||||
.invoke(cli.cli, create_index_unique_args + ["--if-not-exists"])
|
== 0
|
||||||
.exit_code
|
)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_create_index_analyze(db_path):
|
def test_create_index_analyze(db_path):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue