You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by co...@apache.org on 2026/06/25 19:47:33 UTC
(tinkerpop) 16/17: Document why the Go PrimitivePDT test uses a named uint32 type
This is an automated email from the ASF dual-hosted git repository.
Cole-Greer pushed a commit to branch simplePDT
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit ba9f3b45a45721c28138886423d445be783ddbf1
Author: Cole Greer <co...@colegreer.ca>
AuthorDate: Thu Jun 25 09:01:20 2026 -0700
Document why the Go PrimitivePDT test uses a named uint32 type
Go natively serializes the built-in uint32 (emitted as a Gremlin Long), and
that native type-switch in argAsString runs before the PDT registry lookup, so
a bare uint32 never reaches a primitive adapter. The nested integration test
therefore defines a distinct named type (type myUint32 uint32) to opt into PDT
handling. Added a comment explaining this and contrasting with .NET (where
System.UInt32 is not natively serialized and can be registered directly).
Filed tinkerpop-kof to decide whether a registered adapter should take
precedence over native type serialization across all GLVs.
tinkerpop-2gy
Assisted-by: Kiro:claude-opus-4.8
---
gremlin-go/driver/traversal_test.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gremlin-go/driver/traversal_test.go b/gremlin-go/driver/traversal_test.go
index 9e3a8e3da5..0a94e90ddc 100644
--- a/gremlin-go/driver/traversal_test.go
+++ b/gremlin-go/driver/traversal_test.go
@@ -640,6 +640,12 @@ func TestPrimitiveProviderDefinedTypeTraversalAPIIntegration(t *testing.T) {
t.Run("registered primitive nested in composite", func(t *testing.T) {
skipTestsIfNotEnabled(t, integrationTestSuiteName, testNoAuthEnable)
+ // A distinct named type is required to route a value through the PrimitivePDT registry.
+ // Go natively serializes the built-in uint32 (argAsString emits it as a Gremlin Long), and
+ // that native type-switch runs before the PDT registry lookup — so a bare uint32 would never
+ // reach a primitive adapter. Defining myUint32 (a named type based on uint32) opts the type
+ // into PDT handling. This differs from .NET, where System.UInt32 is not natively serialized
+ // and can be registered directly. See tinkerpop-kof for the adapter-vs-native-type precedence follow-up.
type myUint32 uint32
registry := NewPDTRegistry()
registry.RegisterPrimitiveFuncsWithType("x:MyUint32", reflect.TypeOf(myUint32(0)),