This commit is contained in:
Koosha Paridehpour 2026-09-12 23:17:18 -07:00 • committed by GitHub
commit d4397d15f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View file

@ -182,6 +182,8 @@ def column_affinity(column_type: str) -> type:
return bytes
if "REAL" in column_type or "FLOA" in column_type or "DOUB" in column_type:
return float
if "BOOL" in column_type:
return int
if column_type == "ANY":
return ANY
# Default is 'NUMERIC', which we currently also treat as float

View file

@ -102,3 +102,22 @@ def test_flatten(input, expected):
)
def test_dedupe_keys(input, expected):
assert utils.dedupe_keys(input) == expected
@pytest.mark.parametrize(
"column_type,expected",
(
("BOOLEAN", int),
("BOOL", int),
("INTEGER", int),
("TEXT", str),
("REAL", float),
("BLOB", bytes),
("VARCHAR(255)", str),
("DOUBLE PRECISION", float),
("NUMERIC", float),
("", str),
),
)
def test_column_affinity(column_type, expected):
assert utils.column_affinity(column_type) is expected