Detect subclasses of dict/tuple/list, fixes #87

This commit is contained in:
Simon Willison 2020-02-15 18:20:39 -08:00
commit 685e6a1bb3
4 changed files with 9 additions and 5 deletions

View file

@ -621,6 +621,7 @@ def test_create_index_if_not_exists(fresh_db):
["list with", "two items"],
{"dictionary": "simple"},
{"dictionary": {"nested": "complex"}},
collections.OrderedDict([("key1", {"nested": "complex"}), ("key2", "foo"),]),
[{"list": "of"}, {"two": "dicts"}],
),
)

View file

@ -1,4 +1,5 @@
import pytest
from collections import OrderedDict
from sqlite_utils.utils import suggest_column_types
@ -11,6 +12,7 @@ from sqlite_utils.utils import suggest_column_types
([{"a": [1]}], {"a": str}),
([{"a": (1,)}], {"a": str}),
([{"a": {"b": 1}}], {"a": str}),
([{"a": OrderedDict({"b": 1})}], {"a": str}),
([{"a": 1}, {"a": 1.1}], {"a": float}),
([{"a": b"b"}], {"a": bytes}),
],