From 93675dcd3948d527461d7dc12948762a57c9a38e Mon Sep 17 00:00:00 2001 From: Arnau Orriols Date: Tue, 10 Mar 2020 11:51:25 +0100 Subject: [PATCH 1/2] Fix support for dicts without schema rule --- eve/io/mongo/mongo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eve/io/mongo/mongo.py b/eve/io/mongo/mongo.py index d91d7f2b7..8d9fce156 100644 --- a/eve/io/mongo/mongo.py +++ b/eve/io/mongo/mongo.py @@ -857,10 +857,11 @@ def dict_sub_schema(base): elif "schema" in schema[k]: # recursively check the schema return get_schema_type( - keys, dict_sub_schema(schema[k].get("schema")) + keys, dict_sub_schema(schema[k]["schema"]) ) elif schema_type == "dict": - return get_schema_type(keys, dict_sub_schema(schema[k].get("schema"))) + if "schema" in schema[k]: + return get_schema_type(keys, dict_sub_schema(schema[k]["schema"])) else: return schema_type From 963ef76f95d89e26a411838a602ef8b2271f1a16 Mon Sep 17 00:00:00 2001 From: Arnau Orriols Date: Tue, 10 Mar 2020 12:14:10 +0100 Subject: [PATCH 2/2] Change formatting to make black happy --- eve/io/mongo/mongo.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/eve/io/mongo/mongo.py b/eve/io/mongo/mongo.py index 8d9fce156..b84f4bc9b 100644 --- a/eve/io/mongo/mongo.py +++ b/eve/io/mongo/mongo.py @@ -856,9 +856,7 @@ def dict_sub_schema(base): return next((t for t in possible_types if t), None) elif "schema" in schema[k]: # recursively check the schema - return get_schema_type( - keys, dict_sub_schema(schema[k]["schema"]) - ) + return get_schema_type(keys, dict_sub_schema(schema[k]["schema"])) elif schema_type == "dict": if "schema" in schema[k]: return get_schema_type(keys, dict_sub_schema(schema[k]["schema"]))