Skip to content

Commit a7b29bf

Browse files
committed
Fixed bug with sqlite-utils upsert --detect-types, closes #362
1 parent 413f8ed commit a7b29bf

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

sqlite_utils/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,7 @@ def upsert(
10451045
not_null=not_null,
10461046
default=default,
10471047
encoding=encoding,
1048+
detect_types=detect_types,
10481049
load_extension=load_extension,
10491050
silent=silent,
10501051
)

tests/test_cli.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,24 @@ def _test():
19741974
_test()
19751975

19761976

1977+
@pytest.mark.parametrize("option", ("-d", "--detect-types"))
1978+
def test_upsert_detect_types(tmpdir, option):
1979+
db_path = str(tmpdir / "test.db")
1980+
data = "id,name,age,weight\n1,Cleo,6,45.5\n2,Dori,1,3.5"
1981+
result = CliRunner().invoke(
1982+
cli.cli,
1983+
["upsert", db_path, "creatures", "-", "--csv", "--pk", "id"] + [option],
1984+
catch_exceptions=False,
1985+
input=data,
1986+
)
1987+
assert result.exit_code == 0
1988+
db = Database(db_path)
1989+
assert list(db["creatures"].rows) == [
1990+
{"id": 1, "name": "Cleo", "age": 6, "weight": 45.5},
1991+
{"id": 2, "name": "Dori", "age": 1, "weight": 3.5},
1992+
]
1993+
1994+
19771995
@pytest.mark.parametrize(
19781996
"input,expected",
19791997
(

0 commit comments

Comments
 (0)