Skip to content

fix: For new publisher fix error handling for already created constraints/indices #1963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion databuilder/databuilder/utils/publisher_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

LOGGER = logging.getLogger(__name__)

NEO4J_EQUIVALENT_SCHEMA_RULE_ALREADY_EXISTS_ERROR_CODE = 'Neo.ClientError.Schema.EquivalentSchemaRuleAlreadyExists'
NEO4J_INDEX_ALREADY_EXISTS_ERROR_CODE = 'Neo.ClientError.Schema.IndexWithNameAlreadyExists'


def chunkify_list(records: List[dict], chunk_size: int) -> Iterator[List[dict]]:
"""
Expand Down Expand Up @@ -55,7 +58,8 @@ def create_neo4j_node_key_constraint(node_file: str,

session.write_transaction(execute_neo4j_statement, create_stmt)
except Neo4jError as e:
if 'An equivalent constraint already exists' not in e.__str__():
if e.code != NEO4J_EQUIVALENT_SCHEMA_RULE_ALREADY_EXISTS_ERROR_CODE\
and e.code != NEO4J_INDEX_ALREADY_EXISTS_ERROR_CODE:
raise
# Else, swallow the exception, to make this function idempotent.
labels.add(label)
Expand Down
2 changes: 1 addition & 1 deletion databuilder/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

__version__ = '7.2.0'
__version__ = '7.2.1'

requirements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'requirements.txt')
Expand Down