kirill-stepanishin commented on code in PR #3340:
URL: https://github.com/apache/tinkerpop/pull/3340#discussion_r2990398122


##########
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:
   Good catch. Replaced the scientific notation guard with a `MAX_SAFE_INTEGER` 
bounds check. Now values beyond JS safe range get D since they've already lost 
precision as JS number, even if they technically still fit into Java Long.



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