Support of type Long in Cypher queries


(Mstoeckel) #1

Consulting the Neo4j cypher documentation and performing some tests show that it is only possible to use type Integer (and Float) for numbers in Cypher queries. There is no way to store a Long value as property.
E.g. the query
create (n:Person {id:'Me', myLong:15165169950000000000})
returns the error
Neo.ClientError.Statement.SyntaxError: integer is too large (line 1, column 35 (offset: 34))
Also trying to set a long value on an existing node produces the same error. I used the version 3.3.2.
Will there be the possibility in future to be able to use Longs in queries, or is there a workaround that I may use?
Thanks in advance.


(Craig Taverner) #2

The Cypher Integer is the same as the java long, which has a maximum value of 9,223,372,036,854,775,807. The number you used is 15,165,169,950,000,000,000 which is larger than the largest possible long. If you only need to store long values, then Cypher is fine for you. If you need to store larger values, then you need to store them in some other way, either convert to strings and store as a String, or store as two longs (high and low), or serialize to a byte[] and store that.


(Mstoeckel) #3

Thank you very much for your help. I have overlooked, that the value I used is greater than MAX_LONG. So long values are fine for me.