Stephen Mallette created TINKERPOP-3299:
-------------------------------------------
Summary: Python and .NET translators lose BigDecimal scale and
precision for m literals
Key: TINKERPOP-3299
URL: https://issues.apache.org/jira/browse/TINKERPOP-3299
Project: TinkerPop
Issue Type: Bug
Components: translator
Affects Versions: 3.8.2
Reporter: Stephen Mallette
The Python and .NET translators render a gremlin-lang BigDecimal literal
through a floating-point literal. 1250.50m becomes bigdecimal(1250.50) in
Python and (decimal) 1250.50 in C#. Both drop the trailing zero, so the scale
changes from 2 to 1, and both round to double precision, so
0.12345678901234567890m becomes 0.123456789012346 in .NET. The Java, Groovy and
Go translators parse the literal from a string and keep both.
In the Gherkin suite, a scenario that stores 1250.50m and returns it fails in
gremlin-python, because its BigDecimal equality compares scale. Gremlin.Net
passes only because C# decimal equality ignores scale. In both cases the server
receives a different value than the test wrote.
Fix: emit bigdecimal('1250.50') for Python (bigdecimal() already accepts
strings) and 1250.50m for C#. Apply the fix in both the Java translators in
gremlin-core and the TypeScript port in gremlin-javascript, and update
GremlinTranslatorTest and the TypeScript translator tests, which currently
expect bigdecimal(1.0) and (decimal) 1.0.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)