Commit af0ea41
committed
Accept a cdata number as value of a Float variable
It is quite usual that a floating point number is encoded using JSON,
goes over HTTP, received on tarantool server, decoded from JSON and
passed as a variable into the GraphQL executor.
A number out of the [-10^14+1; 10^14-1] range is decoded into Lua as
cdata number[^1] to don't loss the precision. A JSON decoder don't know
that we intend to use this value as the floating point one and chooses
the conservative option: decode the value into cdata number to don't
loss the precision.
In GraphQL we know that it is actually the floating point value
(disregarding its representation in Lua). So it looks correct to accept
a cdata number as value of a Float variable.
The similar idea was expressed in [1] against tarantool itself: let it
accept a number without fractional part as a value suitable for the
`float` field type.
[1]: tarantool/tarantool#5933
[^1]: `cdata<int64_t>` or `cdata<uint64_t>`
Fixes #471 parent 17b642d commit af0ea41
2 files changed
+70
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
322 | 330 | | |
323 | 331 | | |
324 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2051 | 2051 | | |
2052 | 2052 | | |
2053 | 2053 | | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
0 commit comments