Skip to content

Commit

Permalink
positional non located match on 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlatwe committed Apr 27, 2021
1 parent 71af58a commit 991072a
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions montydb/engine/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,9 @@ def __call__(self, fieldwalker):
fieldwalker.go(path).get()

if self.include_flag:
located_match = None
if self.matched is not None:
located_match = self.matched.located

projected = inclusion(fieldwalker,
positioned,
located_match,
self.matched,
init_doc)
else:
projected = exclusion(fieldwalker, init_doc)
Expand Down Expand Up @@ -333,8 +329,9 @@ def _positional_mismatch_v44(matched, elem_count, matched_path, node_path):
_positional_mismatch = _positional_mismatch_v44


def inclusion(fieldwalker, positioned, located_match, init_doc):
def inclusion(fieldwalker, positioned, matched, init_doc):
_doc_type = fieldwalker.doc_type
located_match = matched.located if matched else False

def _inclusion(node, init_doc=None):
doc = node.value
Expand Down Expand Up @@ -368,7 +365,10 @@ def _inclusion(node, init_doc=None):
if isinstance(child.value, _doc_type):
new_doc.append(child.value)
else:
new_doc.append(child.value)
if _include_positional_non_located_match(matched, node):
new_doc.append(child.value)
else:
new_doc.append(_doc_type())

return new_doc or _no_val

Expand Down Expand Up @@ -406,6 +406,18 @@ def _inclusion(node, init_doc=None):
return _inclusion(fieldwalker.tree.root, init_doc)


def _include_positional_non_located_match_(matched, node):
return True


def _include_positional_non_located_match_v44(matched, node):
return matched.full_path.startswith(node.full_path)


_include_positional_non_located_match = \
_include_positional_non_located_match_v44


def exclusion(fieldwalker, init_doc):
_doc_type = fieldwalker.doc_type

Expand Down

0 comments on commit 991072a

Please sign in to comment.