neo4j / cypher-shell

Cypher Shell has moved to https://github.com/neo4j/neo4j
Other
89 stars 48 forks source link

Error when executing a .cypher with a :param line that contains a datetime function #286

Open vga91 opened 3 years ago

vga91 commented 3 years ago

The issue https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/1728 seems to be due to cypher-shell.

Steps to reproduce

Step 1 - Create a .cypher with a :param line that contains a datetime function, like this:

:begin
CREATE CONSTRAINT ON (node:`UNIQUE IMPORT LABEL`) ASSERT (node.`UNIQUE IMPORT ID`) IS UNIQUE;
:commit
:begin
:param rows => [{_id:1, properties:{created:datetime('2020-11-26T21:36:04.212Z')}}]
UNWIND $rows AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n += row.properties SET n:TestNode;
:commit
:begin
MATCH (n:`UNIQUE IMPORT LABEL`)  WITH n LIMIT 20000 REMOVE n:`UNIQUE IMPORT LABEL` REMOVE n.`UNIQUE IMPORT ID`;
:commit
:begin
DROP CONSTRAINT ON (node:`UNIQUE IMPORT LABEL`) ASSERT (node.`UNIQUE IMPORT ID`) IS UNIQUE;
:commit

Step 2 - Execute cat backup.cypher | cypher-shell

klongmitre commented 2 years ago

@vga91 - any update on this? I'm currently facing this same issue? Is there a work-around?

michela commented 1 year ago

This may be related - please advise whether I should create a separate issue.

Using the apoc.export.cypher.all function to write cypher-shell to a file and then use this file as piped input to cypher-shell (as described here) https://neo4j.com/developer/kb/export-sub-graph-to-cypher-and-import/

Any properties of type localdatatime are ignored on input.

e.g. {_id:6295, properties:{lastUpdated:localdatetime('2023-01-12T13:21:44.002'), starred:true, connected_on:"Oct 26)", name:"Michela Ledwidge"}}

Is there a work-around for this?