diff --git a/mongo_connector/doc_managers/formatters.py b/mongo_connector/doc_managers/formatters.py index d5d6fca1..254b2e0b 100644 --- a/mongo_connector/doc_managers/formatters.py +++ b/mongo_connector/doc_managers/formatters.py @@ -163,6 +163,26 @@ def flatten(doc, path): for inner_k, inner_v in flatten(v, path): yield inner_k, inner_v path.pop() + elif isinstance(v, bson.dbref.DBRef): + transformed = self.transform_element("database", v.database) + + for new_k, new_v in transformed: + if top_level: + yield "$%s.%s" % (k, new_k), new_v + else: + yield "$%s.%s.%s" % (path_string, k, new_k), new_v + transformed = self.transform_element("collection", v.collection) + for new_k, new_v in transformed: + if top_level: + yield "$%s.%s" % (k, new_k), new_v + else: + yield "$%s.%s.%s" % (path_string, k, new_k), new_v + transformed = self.transform_element("id", v.id) + for new_k, new_v in transformed: + if top_level: + yield "$%s.%s" % (k, new_k), new_v + else: + yield "$%s.%s.%s" % (path_string, k, new_k), new_v else: transformed = self.transform_element(k, v) for new_k, new_v in transformed: