Skip to content

Commit 4c71009

Browse files
Add explicit EXISTS clause
1 parent 98f8d93 commit 4c71009

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

neomodel/async_/match.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ def _rel_merge_helper(
164164

165165
_UNARY_OPERATORS = (_SPECIAL_OPERATOR_ISNULL, _SPECIAL_OPERATOR_ISNOTNULL)
166166

167-
_REGEX_INSESITIVE = _SPECIAL_OPERATOR_INSENSITIVE + "{}"
167+
_REGEX_INSENSITIVE = _SPECIAL_OPERATOR_INSENSITIVE + "{}"
168168
_REGEX_CONTAINS = ".*{}.*"
169169
_REGEX_STARTSWITH = "{}.*"
170170
_REGEX_ENDSWITH = ".*{}"
171171

172172
# regex operations that require escaping
173173
_STRING_REGEX_OPERATOR_TABLE = {
174-
"iexact": _REGEX_INSESITIVE,
174+
"iexact": _REGEX_INSENSITIVE,
175175
"contains": _REGEX_CONTAINS,
176176
"icontains": _SPECIAL_OPERATOR_INSENSITIVE + _REGEX_CONTAINS,
177177
"startswith": _REGEX_STARTSWITH,
@@ -181,7 +181,7 @@ def _rel_merge_helper(
181181
}
182182
# regex operations that do not require escaping
183183
_REGEX_OPERATOR_TABLE = {
184-
"iregex": _REGEX_INSESITIVE,
184+
"iregex": _REGEX_INSENSITIVE,
185185
}
186186
# list all regex operations, these will require formatting of the value
187187
_REGEX_OPERATOR_TABLE.update(_STRING_REGEX_OPERATOR_TABLE)
@@ -693,16 +693,16 @@ def build_additional_match(self, ident: str, node_set: "AsyncNodeSet") -> None:
693693
for _, value in node_set.must_match.items():
694694
if isinstance(value, dict):
695695
label = ":" + value["node_class"].__label__
696-
stmt = _rel_helper(lhs=source_ident, rhs=label, ident="", **value)
696+
stmt = f"EXISTS ({_rel_helper(lhs=source_ident, rhs=label, ident='', **value)})"
697697
self._ast.where.append(stmt)
698698
else:
699699
raise ValueError("Expecting dict got: " + repr(value))
700700

701701
for _, val in node_set.dont_match.items():
702702
if isinstance(val, dict):
703703
label = ":" + val["node_class"].__label__
704-
stmt = _rel_helper(lhs=source_ident, rhs=label, ident="", **val)
705-
self._ast.where.append("NOT " + stmt)
704+
stmt = f"NOT EXISTS ({_rel_helper(lhs=source_ident, rhs=label, ident='', **val)})"
705+
self._ast.where.append(stmt)
706706
else:
707707
raise ValueError("Expecting dict got: " + repr(val))
708708

neomodel/sync_/match.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ def _rel_merge_helper(
164164

165165
_UNARY_OPERATORS = (_SPECIAL_OPERATOR_ISNULL, _SPECIAL_OPERATOR_ISNOTNULL)
166166

167-
_REGEX_INSESITIVE = _SPECIAL_OPERATOR_INSENSITIVE + "{}"
167+
_REGEX_INSENSITIVE = _SPECIAL_OPERATOR_INSENSITIVE + "{}"
168168
_REGEX_CONTAINS = ".*{}.*"
169169
_REGEX_STARTSWITH = "{}.*"
170170
_REGEX_ENDSWITH = ".*{}"
171171

172172
# regex operations that require escaping
173173
_STRING_REGEX_OPERATOR_TABLE = {
174-
"iexact": _REGEX_INSESITIVE,
174+
"iexact": _REGEX_INSENSITIVE,
175175
"contains": _REGEX_CONTAINS,
176176
"icontains": _SPECIAL_OPERATOR_INSENSITIVE + _REGEX_CONTAINS,
177177
"startswith": _REGEX_STARTSWITH,
@@ -181,7 +181,7 @@ def _rel_merge_helper(
181181
}
182182
# regex operations that do not require escaping
183183
_REGEX_OPERATOR_TABLE = {
184-
"iregex": _REGEX_INSESITIVE,
184+
"iregex": _REGEX_INSENSITIVE,
185185
}
186186
# list all regex operations, these will require formatting of the value
187187
_REGEX_OPERATOR_TABLE.update(_STRING_REGEX_OPERATOR_TABLE)
@@ -691,16 +691,16 @@ def build_additional_match(self, ident: str, node_set: "NodeSet") -> None:
691691
for _, value in node_set.must_match.items():
692692
if isinstance(value, dict):
693693
label = ":" + value["node_class"].__label__
694-
stmt = _rel_helper(lhs=source_ident, rhs=label, ident="", **value)
694+
stmt = f"EXISTS ({_rel_helper(lhs=source_ident, rhs=label, ident='', **value)})"
695695
self._ast.where.append(stmt)
696696
else:
697697
raise ValueError("Expecting dict got: " + repr(value))
698698

699699
for _, val in node_set.dont_match.items():
700700
if isinstance(val, dict):
701701
label = ":" + val["node_class"].__label__
702-
stmt = _rel_helper(lhs=source_ident, rhs=label, ident="", **val)
703-
self._ast.where.append("NOT " + stmt)
702+
stmt = f"NOT EXISTS ({_rel_helper(lhs=source_ident, rhs=label, ident='', **val)})"
703+
self._ast.where.append(stmt)
704704
else:
705705
raise ValueError("Expecting dict got: " + repr(val))
706706

0 commit comments

Comments
 (0)