Cole-Greer commented on code in PR #3427:
URL: https://github.com/apache/tinkerpop/pull/3427#discussion_r3306495862
##########
docs/src/reference/gremlin-variants.asciidoc:
##########
@@ -1969,15 +1970,67 @@ g.V().hasLabel('person').groupCount().by('age')
Either of the above two options accomplishes the desired goal as both prevent
`groupCount()` from having to process
the possibility of `null`.
+[[gremlin-javascript-numeric-types]]
+=== Numeric Types
+
+JavaScript has a single `Number` type (IEEE 754 double) which cannot
distinguish between JVM numeric types. The driver
+provides typed wrapper classes and factory functions that give explicit
control over serialization and deserialization.
+
+==== Controlling Serialization
+
+Wrapping a value selects the GremlinLang type suffix and GraphBinary type code
sent to the server. Without wrappers the
+driver infers types automatically, so existing code is unaffected.
+
+[source,javascript]
+----
+const { toLong, toInt, toFloat, toDouble, toShort, toByte } =
gremlin.structure;
+
+g.V().has('age', toInt(29)).next();
+g.V().has('score', toFloat(3.14)).next();
+g.V().has('id', toLong('9007199254740993')).next();
+----
+
+`toLong()` accepts `number`, `string`, or `bigint`. String and bigint inputs
support the full signed 64-bit range;
+number inputs must be within the safe integer range.
Review Comment:
I can see valid arguments in favour of either approach. Perhaps it's best to
keep the exception for now as it's easier to take away an exception in the
future compared to adding one.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]