mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-10-23 09:47:06 +02:00
Merge 26ca4cef71 into 85b1be10c8
This commit is contained in:
commit
d4397d15f5
2 changed files with 21 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue