Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Neo4j DateTime support #291

Open
Kaston opened this issue Sep 4, 2018 · 6 comments
Open

Native Neo4j DateTime support #291

Kaston opened this issue Sep 4, 2018 · 6 comments

Comments

@Kaston
Copy link

Kaston commented Sep 4, 2018

There is a new DateTime type in neo4j: https://neo4j.com/docs/developer-manual/current/cypher/syntax/temporal/. It would be really great for Neo4jClient to support it.

@cskardon
Copy link
Member

cskardon commented Sep 4, 2018

Agreed - I don't have a timeframe on this - given workloads etc, I'm not even sure I want to hazard a guess. There are some issues around the GraphClient vs BoltGraphClient for this - as I'm aware of some changes which will necessitate some big changes - I will look into this when I can though

@richardu
Copy link

richardu commented Apr 6, 2021

Is this issue really still open, or does Neo4jClient support the Neo4j native DATE_TIME now? (aside from the use of the Neo4jDateTime attribute.)

I described the problem I'm having here here:
https://stackoverflow.com/questions/66872103/how-to-store-c-sharp-datetime-as-neo4j-date-time-instead-of-string-using-neo4jcl
but perhaps I'm doing something wrong...

@cskardon
Copy link
Member

cskardon commented Apr 8, 2021

Yup, it's still open.
But thank you for reminding me, I'll try to get around to it, but - well, work and time are the big blockers here.

@richardu
Copy link

richardu commented Apr 12, 2021

Hi @cskardon I had a quick look - seems to work if you just do this in Neo4jDriverExtensions.cs:

private static object SerializePrimitive(Type type, TypeInfo typeInfo, object instance)
{
    if (type == typeof(DateTime))
    {
        // return SerializeDateTime((DateTime) instance);
        return instance;
    }

    if (type == typeof(DateTimeOffset))
    {
        //return SerializeDateTimeOffset((DateTimeOffset) instance);
        return instance;
    }
...

Needs a bunch of tests to be sure it works 100% of the time though.

Took me a while to figure out this only works with the Bolt client and not the HTTP client!

@cskardon
Copy link
Member

Well, yes, but that would break everyone else's code.
So we'd need probably to have it as a config option as part of the Client itself, and also make it work for REST and Bolt, plus the tests.

What it can't do is change how datetimes are handled by default, as that's a very large change that would break a lot of things.

By all means, PR just the bolt one and I'll look at retrofitting it into the REST version!

@richardu
Copy link

Hehehe, it would indeed! I didn't just submit a PR a) because of this and b) as you say, it needs to be properly configurable. TBH I thought you'd be best at deciding how you wanted it done, given there are probably several options...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants