Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sqlite_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def guessed_type(self) -> str:
return "text"

def evaluate(self, value: object) -> None:
if not value or not self.couldbe:
if value is None or not self.couldbe:
return
not_these: List[str] = []
for name, test in self.couldbe.items():
Expand Down
18 changes: 18 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from sqlite_utils import utils
from sqlite_utils.utils import TypeTracker
import csv
import io
import pytest
Expand Down Expand Up @@ -73,6 +74,23 @@ def test_maximize_csv_field_size_limit():
assert rows_list2[0]["text"] == long_value


@pytest.mark.parametrize(
"rows,expected_types",
[
([{"a": ""}], {"a": "text"}),
([{"a": ""}, {"a": ""}], {"a": "text"}),
([{"a": "1"}, {"a": ""}], {"a": "text"}),
([{"a": "0"}], {"a": "integer"}),
([{"a": "1"}], {"a": "integer"}),
([{"a": None}], {"a": "integer"}),
],
)
def test_type_tracker_empty_strings(rows, expected_types):
tracker = TypeTracker()
list(tracker.wrap(iter(rows)))
assert tracker.types == expected_types


@pytest.mark.parametrize(
"input,expected",
(
Expand Down
Loading