cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Linebreaks lost on node.setProperty

Jiropole
Graph Voyager

I'm having an odd issue where line-break characters in strings are converted to the \n string when copying properties between nodes. The code for copying properties is basically lifted from APOC:

private <T extends PropertyContainer> T copyProperties(Map<String, Object> source, T target) {
    for (Map.Entry<String, Object> prop : source.entrySet())
        target.setProperty(prop.getKey(), prop.getValue());
    return target;
}

Didn't find any Github issues related to this, so I'm wondering what I might be missing? Ideas appreciated.

2 REPLIES 2

Hi Jiropole,

The \n character is the Java representation of a newline character within a string, so that seems correct to us.

Thanks Andrew,

Sure, it's the string literal representation, but what I'm seeing is the line break character encoded in the original string being replaced with a literal \n in the copied value, i.e. the value is being transformed, versus copied verbatim. That doesn't seem to make sense, as the code doesn't suggest to me any transformation. Or, if that's a wrong analysis, how would I ensure the value is not transformed when copied?

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online