Home » Java » Enterprise Java » Neo4j: Cypher – Neo.ClientError.Statement.TypeError: Don’t know how to add Double and String

About Mark Needham

Mark Needham

Neo4j: Cypher – Neo.ClientError.Statement.TypeError: Don’t know how to add Double and String

I recently upgraded a Neo4j backed application from Neo4j 3.2 to Neo4j 3.3 and came across an interesting change in behaviour around type coercion which led to my application throwing a bunch of errors.

In Neo4j 3.2 and earlier if you added a String to a Double it would coerce the Double to a String and concatenate the values. The following would therefore be valid Cypher:

RETURN toFloat("1.0") + " Mark"
 
╒══════════╕
│"result"  │
╞══════════╡
│"1.0 Mark"│
└──────────┘

This behaviour has changed in the 3.3 series and will instead throw an exception:

RETURN toFloat("1.0") + " Mark"
 
Neo.ClientError.Statement.TypeError: Don't know how to add `Double(1.000000e+00)` and `String(" Mark")`

We can workaround that by forcing our query to run in 3.2 mode:

CYPHER 3.2
RETURN toFloat("1.0") + " Mark" AS result

or we can convert the Double to a String in our Cypher statement:

RETURN toString(toFloat("1.0")) + " Mark" AS result
Published on Java Code Geeks with permission by Mark Needham, partner at our JCG program. See the original article here: Neo4j: Cypher – Neo.ClientError.Statement.TypeError: Don’t know how to add Double and String

Opinions expressed by Java Code Geeks contributors are their own.

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments