Cole-Greer commented on code in PR #3340:
URL: https://github.com/apache/tinkerpop/pull/3340#discussion_r2984890878


##########
gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/gremlin-lang.ts:
##########
@@ -71,15 +71,24 @@ export default class GremlinLang {
     if (arg instanceof Long) {
       return String(arg.value) + 'L';
     }
-    if (arg instanceof Date) {
-      const iso = arg.toISOString();
-      return `datetime("${iso}")`;
+    if (typeof arg === 'bigint') {
+      return String(arg) + 'N';
     }
     if (typeof arg === 'number') {
       if (Number.isNaN(arg)) return 'NaN';
       if (arg === Infinity) return '+Infinity';
       if (arg === -Infinity) return '-Infinity';
-      return String(arg);
+      if (!Number.isInteger(arg)) return String(arg) + 'D';
+      if (arg >= -2147483648 && arg <= 2147483647) return String(arg);
+      const s = String(arg);
+      // Values >= 1e21 stringify in scientific notation (e.g. 
"1.7976931348623157e+308"),
+      // which the Gremlin parser cannot handle with an L suffix — emit D 
instead.
+      if (s.includes('e') || s.includes('E')) return s + 'D';
+      return s + 'L';

Review Comment:
   I think this may also need a bounds check on Java's Long.MAX_VALUE and 
Long.MIN_VALUE. Max long is about 9e19, in theory there should be some `number` 
values which are greater than Java's Long.MAX_VALUE, but 
`Number.isInteger(arg)` is also true. These cases should retain a `D` suffix.



-- 
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]

Reply via email to