diff --git a/mongoframes/frames.py b/mongoframes/frames.py index 57807c0..a62a49c 100644 --- a/mongoframes/frames.py +++ b/mongoframes/frames.py @@ -638,18 +638,26 @@ def _flatten_projection(cls, projection): inclusive = True for key, value in deepcopy(projection).items(): if isinstance(value, dict): - # Check for $meta projections - if '$meta' in value: - flat_projection[key] = value - continue + + # Build the projection value for the field (allowing for + # special mongo directives). + project_value = { + k: v for k, v in value.items() + if k.startswith('$') and k not in ['$ref', '$sub', '$sub.'] + } + if len(project_value) == 0: + project_value = True + else: + inclusive = False # Store a reference/sub-frame projection if '$ref' in value: references[key] = value + elif '$sub' in value or '$sub.' in value: subs[key] = value - flat_projection[key] = True + flat_projection[key] = project_value elif key == '$ref': # Strip any $ref key diff --git a/setup.py b/setup.py index a10711f..e8b66c8 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='1.2.12', + version='1.2.13', description='A fast unobtrusive MongoDB ODM for Python', long_description=long_description,