From e34b93bdca790619bcd308d7eba104030f278e7f Mon Sep 17 00:00:00 2001 From: Dave Voutila Date: Wed, 12 Apr 2023 11:40:50 -0400 Subject: [PATCH] unbreak graph import Bad logic resulted in not sending the database name when doing a projection, so wire in some more conditionals. The start method is now a mess, but let's get it working for now. --- neo4j_arrow/_client.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/neo4j_arrow/_client.py b/neo4j_arrow/_client.py index b9c9b42..1dbc783 100644 --- a/neo4j_arrow/_client.py +++ b/neo4j_arrow/_client.py @@ -227,13 +227,27 @@ def _write_batches(self, desc: Dict[str, Any], def start(self, action: str = "CREATE_GRAPH", *, config: Dict[str, Any] = {}, force: bool = False) -> Dict[str, Any]: + """ + Start an import job. Defaults to graph (projection) import. + + Note: for database creation, you must currently set action to the string + value "CREATE_DATABASE". If doing so, force will determine if we attempt + to overrite any existing database. + + TODO: XXX: this method needs rework into 2 different methods + """ assert not self.debug or self.state == ClientState.READY if not config: config = { "name": self.graph, "concurrency": self.concurrency, - "force": force, } + if action == "CREATE_DATABASE": + if force: + config.update({ "force": force }) + else: + config.update({ "database_name": self.database }) + # TODO: assert config has mandatory fields try: result = self._send_action(action, config)