You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "xiazcy (via GitHub)" <gi...@apache.org> on 2025/07/29 00:15:41 UTC
[PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
xiazcy opened a new pull request, #3168:
URL: https://github.com/apache/tinkerpop/pull/3168
Given OffsetDateTime serializers were implemented in master/3.8, this is a back-port for convenience of the ability to deserialize from OffsetDateTime into native date types. Do note that while the serializers were backported for some GLVs h, Date remains the default serialized types for GLV native date types.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3168:
URL: https://github.com/apache/tinkerpop/pull/3168#discussion_r2241096375
##########
gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs:
##########
@@ -108,6 +108,19 @@ public void ShouldDeserializeDateToDateTimeOffset(int version)
Assert.Equal(expectedDateTimeOffset, deserializedValue);
}
+ [Theory, MemberData(nameof(Versions))]
+ public void ShouldDeserializeOffsetDateTimeToDateTimeOffset(int version)
+ {
+ const string graphSon = "{\"@type\":\"gx:OffsetDateTime\",\"@value\":\"2016-10-04T12:17:22.5520000+00:00\"}";
+ var reader = CreateStandardGraphSONReader(version);
+
+ var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon);
+ var deserializedValue = reader.ToObject(jsonElement);
+
+ var expectedDateTimeOffset = TestUtils.FromJavaTime(1475583442552);
Review Comment:
```suggestion
const string dateTimeString = "2016-10-04T12:17:22.5520000+00:00";
const string graphSon = "{\"@type\":\"gx:OffsetDateTime\",\"@value\":\"" + dateTimeString + "\"}";
var reader = CreateStandardGraphSONReader(version);
var jsonElement = JsonSerializer.Deserialize<JsonElement>(graphSon);
var deserializedValue = reader.ToObject(jsonElement);
var expectedDateTimeOffset = DateTimeOffset.Parse(dateTimeString);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on PR #3168:
URL: https://github.com/apache/tinkerpop/pull/3168#issuecomment-3134161799
> this is a back-port for convenience of the ability to deserialize from OffsetDateTime into native date types.
Do we not need to also support serialization of `OffsetDateTime?`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on code in PR #3168:
URL: https://github.com/apache/tinkerpop/pull/3168#discussion_r2243719335
##########
gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/OffsetDateTimeSerializer.cs:
##########
Review Comment:
Yes, that is correct. This is more of a connivence back-port for the ability to deserialize potential OffsetDateTime from server in the GLVs (Java has the support already). I don't quite expect this to be used per se, but the difference would be a deserialization error vs successful deserialization.
Potential downside is that OffsetDateTime will not be able to round-trip, given GLVs still use Date as default type for native date supports.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3168:
URL: https://github.com/apache/tinkerpop/pull/3168#discussion_r2241140414
##########
gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js:
##########
@@ -89,6 +89,12 @@ describe('GraphSONReader', function () {
const result = reader.read(obj);
assert.ok(result instanceof Date);
});
+ it('should parse OffsetDateTime', function() {
+ const obj = { "@type" : "gx:OffsetDateTime", "@value" : "2016-12-14T21:14:36.295Z" };
+ const reader = new GraphSONReader();
+ const result = reader.read(obj);
+ assert.ok(result instanceof Date);
Review Comment:
Can you add some verification of the day, month, year values etc?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on PR #3168:
URL: https://github.com/apache/tinkerpop/pull/3168#issuecomment-4994480989
Closing this PR as I had been on the fence about the usefulness of adding OffsetDateTime deserialization support, when Date is the default and there won't be round-trip capability anyways.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3168:
URL: https://github.com/apache/tinkerpop/pull/3168#discussion_r2241125645
##########
gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/OffsetDateTimeSerializer.cs:
##########
Review Comment:
I just want to clarify that I'm understanding this correctly. This `OffsetDateTimeSerializer` will not be used until 3.8 and is not being used in 3.7.4. This was not added to the `GraphSONWriter.cs` logic because for 3.7.4 we are still serializing `DateTimeOffset` as `Date` and there is no way to write `OffsetDateTime` to a request.
Is my understanding correct? If so, is there any value with adding this `OffsetDateTimeSerializer`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3168:
URL: https://github.com/apache/tinkerpop/pull/3168#discussion_r2241143310
##########
gremlin-python/src/main/python/gremlin_python/structure/io/graphbinaryV1.py:
##########
@@ -343,6 +343,43 @@ def objectify(cls, buff, reader, nullable=True):
nullable)
+class OffsetDateTimeDeserializer(_GraphBinaryTypeIO):
Review Comment:
```suggestion
class OffsetDateTimeIO(_GraphBinaryTypeIO):
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Backport OffsetDateTime serializers in GLVs to enable deserialization from server [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy closed pull request #3168: Backport OffsetDateTime serializers in GLVs to enable deserialization from server
URL: https://github.com/apache/tinkerpop/pull/3168
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org