mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-27 03:14:33 +02:00
This commit is contained in:
parent
0dbf4b2775
commit
d138a60deb
4 changed files with 74 additions and 3 deletions
|
|
@ -224,6 +224,17 @@ def test_create_index(db_path):
|
|||
)
|
||||
|
||||
|
||||
def test_create_index_analyze(db_path):
|
||||
db = Database(db_path)
|
||||
assert "sqlite_stat1" not in db.table_names()
|
||||
assert [] == db["Gosh"].indexes
|
||||
result = CliRunner().invoke(
|
||||
cli.cli, ["create-index", db_path, "Gosh", "c1", "--analyze"]
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "sqlite_stat1" in db.table_names()
|
||||
|
||||
|
||||
def test_create_index_desc(db_path):
|
||||
db = Database(db_path)
|
||||
assert [] == db["Gosh"].indexes
|
||||
|
|
@ -889,6 +900,20 @@ def test_upsert(db_path, tmpdir):
|
|||
]
|
||||
|
||||
|
||||
def test_upsert_analyze(db_path, tmpdir):
|
||||
db = Database(db_path)
|
||||
db["rows"].insert({"id": 1, "foo": "x", "n": 3}, pk="id")
|
||||
db["rows"].create_index(["n"])
|
||||
assert "sqlite_stat1" not in db.table_names()
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
["upsert", db_path, "rows", "-", "--nl", "--analyze", "--pk", "id"],
|
||||
input='{"id": 2, "foo": "bar", "n": 1}',
|
||||
)
|
||||
assert 0 == result.exit_code, result.output
|
||||
assert "sqlite_stat1" in db.table_names()
|
||||
|
||||
|
||||
def test_upsert_flatten(tmpdir):
|
||||
db_path = str(tmpdir / "flat.db")
|
||||
db = Database(db_path)
|
||||
|
|
|
|||
|
|
@ -327,6 +327,20 @@ def test_insert_alter(db_path, tmpdir):
|
|||
] == list(db.query("select foo, n, baz from from_json_nl"))
|
||||
|
||||
|
||||
def test_insert_analyze(db_path):
|
||||
db = Database(db_path)
|
||||
db["rows"].insert({"foo": "x", "n": 3})
|
||||
db["rows"].create_index(["n"])
|
||||
assert "sqlite_stat1" not in db.table_names()
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
["insert", db_path, "rows", "-", "--nl", "--analyze"],
|
||||
input='{"foo": "bar", "n": 1}\n{"foo": "baz", "n": 2}',
|
||||
)
|
||||
assert 0 == result.exit_code, result.output
|
||||
assert "sqlite_stat1" in db.table_names()
|
||||
|
||||
|
||||
def test_insert_lines(db_path):
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue