@classmethod<EOL><INDENT>def _build_merge_query(cls, merge_params, update_existing=False, lazy=False, relationship=None):<DEDENT>
query_params = dict(merge_params=merge_params)<EOL>n_merge = "<STR_LIT>".format(<EOL>"<STR_LIT::>".join(cls.inherited_labels()),<EOL>"<STR_LIT:U+002CU+0020>".join("<STR_LIT>".format(getattr(cls, p).db_property or p) for p in cls.__required_properties__))<EOL>if relationship is None:<EOL><INDENT>query = "<STR_LIT>".format(n_merge)<EOL><DEDENT>else:<EOL><INDENT>if not isinstance(relationship.source, StructuredNode):<EOL><INDENT>raise ValueError("<STR_LIT>".format(repr(relationship.source)))<EOL><DEDENT>relation_type = relationship.definition.get('<STR_LIT>')<EOL>if not relation_type:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>from .match import _rel_helper<EOL>query_params["<STR_LIT>"] = relationship.source.id<EOL>query = "<STR_LIT>".format(relationship.source.__label__)<EOL>query += "<STR_LIT>"<EOL>query += "<STR_LIT>"<EOL>query += _rel_helper(lhs='<STR_LIT:source>', rhs=n_merge, ident=None,<EOL>relation_type=relation_type, direction=relationship.definition['<STR_LIT>'])<EOL><DEDENT>query += "<STR_LIT>"<EOL>if update_existing is True:<EOL><INDENT>query += "<STR_LIT>"<EOL><DEDENT>if lazy:<EOL><INDENT>query += "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>query += "<STR_LIT>"<EOL><DEDENT>return query, query_params<EOL>
Get a tuple of a CYPHER query and a params dict for the specified MERGE query.

:param merge_params: The target node match parameters, each node must have a "create" key and optional "update".
:type merge_params: list of dict
:param update_existing: True to update properties of existing nodes, default False to keep existing values.
:type update_existing: bool
:rtype: tuple