cypher-query-builder
cypher-query-builder copied to clipboard
Transformation of Temporal type
Hi,
I am experimenting with this package and it all looks promising. Thank you for the hard work!
I am running across a small issue though.
I am using neo4j date()
and datetime()
types in some properties.
When getting the result back from neo4j in a query, those properties come back as instances of neo4jDriver.v1.types.Date
and neo4jDriver.v1.types.DateTime
(see Temporal types).
However, when going through the transformer, they get transformed into standard objects here.
This means that I cannot use neo4jDriver.v1.isDate
or neo4jDriver.v1.isDateTime
anymore on them later on in my code for custom handling (in my case I use them to determine how to format them).
I would expect the transformer to either:
- transform them into a
Date
object - return a formatted string (based on the type)
- return them as-is
In fact, I am thinking that it would also be great to be able to inject a custom Transformer
into the Connection
. That would allow custom transformations.
In the case of date objects, it might be useful for localization, for example.
I haven't tested yet, but similar issues will likely happen with Duration
, Type
, Localtime
, Point
, etc.
See also https://neo4j.com/docs/driver-manual/1.7/cypher-values/#driver-neo4j-type-system
What do you think?
Thanks you
Hi there. Thanks for raising this issue. I think returning them as is may be the best solution. This will be considered a breaking change though so it will be part of the next major release. I'll see what I can do about the custom transformer, other people have raised the same suggestion so it can probably be part of the same release.
Great. Thank you.