mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
Handle dict/tuple/list mapping to TEXT, closes #338
This commit is contained in:
parent
84007dffa8
commit
9cda5b070f
2 changed files with 29 additions and 0 deletions
|
|
@ -168,6 +168,8 @@ COLUMN_TYPE_MAPPING = {
|
|||
bool: "INTEGER",
|
||||
str: "TEXT",
|
||||
dict: "TEXT",
|
||||
tuple: "TEXT",
|
||||
list: "TEXT",
|
||||
bytes.__class__: "BLOB",
|
||||
bytes: "BLOB",
|
||||
memoryview: "BLOB",
|
||||
|
|
|
|||
|
|
@ -1040,3 +1040,30 @@ def test_create_with_nested_bytes(fresh_db):
|
|||
)
|
||||
def test_quote(fresh_db, input, expected):
|
||||
assert fresh_db.quote(input) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"columns,expected_sql_middle",
|
||||
(
|
||||
(
|
||||
{"id": int},
|
||||
"[id] INTEGER",
|
||||
),
|
||||
(
|
||||
{"col": dict},
|
||||
"[col] TEXT",
|
||||
),
|
||||
(
|
||||
{"col": tuple},
|
||||
"[col] TEXT",
|
||||
),
|
||||
(
|
||||
{"col": list},
|
||||
"[col] TEXT",
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_create_table_sql(fresh_db, columns, expected_sql_middle):
|
||||
sql = fresh_db.create_table_sql("t", columns)
|
||||
middle = sql.split("(")[1].split(")")[0].strip()
|
||||
assert middle == expected_sql_middle
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue