diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index ab27761..624f47e 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -1045,6 +1045,7 @@ def upsert( not_null=not_null, default=default, encoding=encoding, + detect_types=detect_types, load_extension=load_extension, silent=silent, ) diff --git a/tests/test_cli.py b/tests/test_cli.py index c4c50a9..b789b1e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1974,6 +1974,24 @@ def test_insert_detect_types(tmpdir, option_or_env_var): _test() +@pytest.mark.parametrize("option", ("-d", "--detect-types")) +def test_upsert_detect_types(tmpdir, option): + db_path = str(tmpdir / "test.db") + data = "id,name,age,weight\n1,Cleo,6,45.5\n2,Dori,1,3.5" + result = CliRunner().invoke( + cli.cli, + ["upsert", db_path, "creatures", "-", "--csv", "--pk", "id"] + [option], + catch_exceptions=False, + input=data, + ) + assert result.exit_code == 0 + db = Database(db_path) + assert list(db["creatures"].rows) == [ + {"id": 1, "name": "Cleo", "age": 6, "weight": 45.5}, + {"id": 2, "name": "Dori", "age": 1, "weight": 3.5}, + ] + + @pytest.mark.parametrize( "input,expected", (