mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-19 23:14:09 +02:00
Guard transform when --detect-types CSV has only a header row (closes #702)
This commit is contained in:
parent
8d74ffc932
commit
633414a556
2 changed files with 16 additions and 1 deletions
|
|
@ -2305,6 +2305,21 @@ def test_insert_detect_types(tmpdir, option):
|
|||
]
|
||||
|
||||
|
||||
def test_insert_detect_types_header_only_csv(tmpdir):
|
||||
"""Test that --detect-types does not crash for CSV with only a header row"""
|
||||
db_path = str(tmpdir / "test.db")
|
||||
data = "name,age,weight\n"
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
["insert", db_path, "creatures", "-", "--csv", "--detect-types"],
|
||||
catch_exceptions=False,
|
||||
input=data,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
db = Database(db_path)
|
||||
assert "creatures" not in db.table_names()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("option", (None, "-d", "--detect-types"))
|
||||
def test_upsert_detect_types(tmpdir, option):
|
||||
"""Test that type detection is now the default behavior for upsert"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue