mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-22 00:14:15 +02:00
fix(cli): skip transform when table missing after header-only CSV (fixes #702)
insert_upsert_implementation and memory multi-file import call Table.transform() after TypeTracker runs. For a CSV with only a header row, insert_all yields no rows and may not create the table; transform() then asserted. Only run transform when the table exists. Covers both the insert command path and the memory command path. Made-with: Cursor
This commit is contained in:
parent
8d74ffc932
commit
a6b3812fc7
2 changed files with 17 additions and 2 deletions
|
|
@ -2327,6 +2327,21 @@ def test_upsert_detect_types(tmpdir, option):
|
|||
]
|
||||
|
||||
|
||||
def test_insert_csv_header_only_detect_types_no_crash(tmpdir):
|
||||
"""Header-only CSV with default type detection must not crash (issue #702)."""
|
||||
db_path = str(tmpdir / "test.db")
|
||||
data = "name,age,weight\n"
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
["insert", db_path, "creatures", "-", "--csv"],
|
||||
catch_exceptions=False,
|
||||
input=data,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
db = Database(db_path)
|
||||
assert not db["creatures"].exists()
|
||||
|
||||
|
||||
def test_csv_detect_types_creates_real_columns(tmpdir):
|
||||
"""Test that CSV import creates REAL columns for floats (default behavior)"""
|
||||
db_path = str(tmpdir / "test.db")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue