File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -187,12 +187,12 @@ cdef class BuilderManager:
187187 raise ValueError (" Could not append raw value to" , full_key.decode(' utf8' ))
188188
189189 # Recurse into documents.
190- if value_t == BSON_TYPE_DOCUMENT:
190+ if value_t == BSON_TYPE_DOCUMENT and builder.type_marker == BSON_TYPE_DOCUMENT :
191191 bson_iter_recurse(doc_iter, & child_iter)
192192 self .parse_document(& child_iter, full_key, BSON_TYPE_DOCUMENT)
193193
194194 # Recurse into arrays.
195- if value_t == BSON_TYPE_ARRAY:
195+ if value_t == BSON_TYPE_ARRAY and builder.type_marker == BSON_TYPE_ARRAY :
196196 bson_iter_recurse(doc_iter, & child_iter)
197197 self .parse_document(& child_iter, full_key, BSON_TYPE_ARRAY)
198198
Original file line number Diff line number Diff line change @@ -492,6 +492,12 @@ def test_schema_missing_field(self):
492492 out = func (self .coll , {} if func == find_arrow_all else [], schema = schema ).drop (["_id" ])
493493 self .assertEqual (out ["list_field" ].to_pylist (), expected )
494494
495+ def test_schema_incorrect_data_type (self ):
496+ self .coll .delete_many ({})
497+ self .coll .insert_one ({"x" : {"y" : 1 }})
498+ out = find_arrow_all (self .coll , {}, schema = Schema ({"x" : str }))
499+ assert out .to_pylist () == [{"x" : None }]
500+
495501 def test_auto_schema_nested (self ):
496502 # Create table with random data of various types.
497503 _ , data = self ._create_nested_data ()
You can’t perform that action at this time.
0 commit comments