jsonatapy 2.2.16__tar.gz → 2.2.17__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/CHANGELOG.md +40 -0
  2. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/Cargo.lock +1 -1
  3. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/Cargo.toml +1 -1
  4. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/PKG-INFO +4 -4
  5. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/README.md +3 -3
  6. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/pyproject.toml +1 -1
  7. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/builtins.rs +24 -5
  8. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/datetime.rs +176 -9
  9. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/evaluator.rs +376 -78
  10. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.gitignore +0 -0
  11. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.gitmodules +0 -0
  12. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.serena/.gitignore +0 -0
  13. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.serena/memories/architecture.md +0 -0
  14. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.serena/memories/conventions.md +0 -0
  15. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.serena/memories/core.md +0 -0
  16. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.serena/memories/memory_maintenance.md +0 -0
  17. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.serena/memories/suggested_commands.md +0 -0
  18. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.serena/memories/task_completion.md +0 -0
  19. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/.serena/memories/tech_stack.md +0 -0
  20. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/CONTRIBUTORS.md +0 -0
  21. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/LICENSE +0 -0
  22. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/SECURITY.md +0 -0
  23. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/benches/evaluator_bench.rs +0 -0
  24. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/bindings/c/README.md +0 -0
  25. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/bindings/c/examples/smoke.c +0 -0
  26. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/bindings/c/jsonata.h +0 -0
  27. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/examples/evaluator_demo.rs +0 -0
  28. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/examples/host_functions.rs +0 -0
  29. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/examples/parser_demo.rs +0 -0
  30. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/examples/simd_json_bench.rs +0 -0
  31. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/__init__.py +0 -0
  32. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/__main__.py +0 -0
  33. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/_cli/__init__.py +0 -0
  34. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/_cli/bindings.py +0 -0
  35. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/_cli/error_format.py +0 -0
  36. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/_cli/mcp_server.py +0 -0
  37. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/_cli/resolve.py +0 -0
  38. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/_cli/run.py +0 -0
  39. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/python/jsonatapy/py.typed +0 -0
  40. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/allocator.rs +0 -0
  41. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/ast.rs +0 -0
  42. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/ast_transform.rs +0 -0
  43. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/bin/jsonata/bindings.rs +0 -0
  44. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/bin/jsonata/error_format.rs +0 -0
  45. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/bin/jsonata/main.rs +0 -0
  46. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/bin/jsonata/resolve.rs +0 -0
  47. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/capi.rs +0 -0
  48. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/compiler.rs +0 -0
  49. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/expression.rs +0 -0
  50. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/functions.rs +0 -0
  51. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/lazy.rs +0 -0
  52. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/lib.rs +0 -0
  53. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/parser.rs +0 -0
  54. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/pystack.rs +0 -0
  55. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/signature.rs +0 -0
  56. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/value.rs +0 -0
  57. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/src/vm.rs +0 -0
  58. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/study/cli_fixtures.json +0 -0
  59. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/study/cli_fixtures_testdata.json +0 -0
  60. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/study/cli_spec.md +0 -0
  61. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/array_flags_test.rs +0 -0
  62. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/cli_fixtures_test.rs +0 -0
  63. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/cli_test.rs +0 -0
  64. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/common/mod.rs +0 -0
  65. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/datetime_picture_suite.rs +0 -0
  66. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/deep_value_drop_test.rs +0 -0
  67. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/evaluator_reuse_test.rs +0 -0
  68. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/array_flags_differential.json +0 -0
  69. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/builtin_arity.json +0 -0
  70. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/builtin_differential.json +0 -0
  71. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/builtin_signatures.json +0 -0
  72. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/fastpath_differential.json +0 -0
  73. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/fastpath_known_divergences.json +0 -0
  74. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/path_semantics_combinations.json +0 -0
  75. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/path_semantics_combinations_known.json +0 -0
  76. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/fixtures/path_semantics_differential.json +0 -0
  77. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/host_functions_test.rs +0 -0
  78. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/integration_test.rs +0 -0
  79. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/lambda_closure_suite.rs +0 -0
  80. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/parent_and_focus_binding_suite.rs +0 -0
  81. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/path_semantics_test.rs +0 -0
  82. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/tests/step_cache_test.rs +0 -0
  83. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/Cargo.toml +0 -0
  84. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/LICENSE.txt +0 -0
  85. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/VENDORED.md +0 -0
  86. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/build.rs +0 -0
  87. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/LICENSE +0 -0
  88. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc/atomic.h +0 -0
  89. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc/bits.h +0 -0
  90. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc/internal.h +0 -0
  91. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc/prim-tls.h +0 -0
  92. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc/prim.h +0 -0
  93. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc/track.h +0 -0
  94. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc/types.h +0 -0
  95. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc-new-delete.h +0 -0
  96. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc-override.h +0 -0
  97. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc-stats.h +0 -0
  98. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc.h +0 -0
  99. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/alloc-aligned.c +0 -0
  100. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/alloc-override.c +0 -0
  101. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/alloc-posix.c +0 -0
  102. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/alloc.c +0 -0
  103. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/arena-meta.c +0 -0
  104. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/arena.c +0 -0
  105. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/bitmap.c +0 -0
  106. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/bitmap.h +0 -0
  107. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/free.c +0 -0
  108. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/heap.c +0 -0
  109. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/init.c +0 -0
  110. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/libc.c +0 -0
  111. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/options.c +0 -0
  112. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/os.c +0 -0
  113. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/page-map.c +0 -0
  114. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/page-queue.c +0 -0
  115. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/page.c +0 -0
  116. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/emscripten/prim.c +0 -0
  117. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/osx/alloc-override-zone.c +0 -0
  118. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/osx/prim.c +0 -0
  119. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/prim.c +0 -0
  120. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/readme.md +0 -0
  121. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/unix/prim.c +0 -0
  122. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/wasi/prim.c +0 -0
  123. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/windows/etw-mimalloc.wprp +0 -0
  124. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/windows/etw.h +0 -0
  125. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/windows/etw.man +0 -0
  126. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/windows/prim.c +0 -0
  127. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/prim/windows/readme.md +0 -0
  128. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/random.c +0 -0
  129. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/static.c +0 -0
  130. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/stats.c +0 -0
  131. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/theap.c +0 -0
  132. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/c_src/mimalloc/v3/src/threadlocal.c +0 -0
  133. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/src/extended.rs +0 -0
  134. {jsonatapy-2.2.16 → jsonatapy-2.2.17}/vendor/libmimalloc-sys/src/lib.rs +0 -0
@@ -19,6 +19,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
19
19
 
20
20
  ### Security
21
21
 
22
+ ## [2.2.17] - 2026-11-28
23
+
24
+ ### Added
25
+
26
+ ### Changed
27
+
28
+ ### Deprecated
29
+
30
+ ### Removed
31
+
32
+ ### Fixed
33
+
34
+ - The transform operator (`~> | location | update |`) now changes only the
35
+ objects its location matches, by identity, as jsonata-js does. It used to
36
+ match by value, so `{"b":{"a":1},"c":{"a":1}} ~> | b | {"x":2} |` changed
37
+ `c` too. Matches now also apply in order, each to the object as earlier
38
+ matches left it, and the delete clause sees the object after its update.
39
+ A location that matches an object outside the input's copy (one it built,
40
+ such as `{}` or `$merge([a])`) raises D1014, as in jsonata-js 2.3.0.
41
+ - Inputs that panicked or exhausted memory now give a result or a coded
42
+ error, following the limits jsonata-js 2.3.0 added for them:
43
+ - `$pad` raises D2016 when the padding would exceed 1e7 characters
44
+ (jsonata-js #832). A huge width no longer saturates to 2^31 and
45
+ allocates gigabytes.
46
+ - `$formatInteger` (and date/time pictures) format numbers above 1e7 as
47
+ decimal digits instead of roman numerals, so `$formatInteger(-1e15, 'i')`
48
+ no longer tries to build 1e12 `M`s.
49
+ - A date/time width modifier above 100 raises D3142, so `[Y,600000000]`
50
+ no longer divides by zero and `[f,150000000]` no longer builds a
51
+ 150-million-character string. `[Y,100]` no longer panics on `10^100`.
52
+ - `$parseInteger('12', '١')` (ASCII digits with a picture in another digit
53
+ family) no longer panics, and `$fromMillis(0, '[fN]')` raises D3133
54
+ instead of panicking.
55
+ - `$toMillis` returns undefined, without building the regex, when the
56
+ timestamp is shorter than the picture needs or matching it would be too
57
+ large, so a picture with 100,000 markers or a 10-million-character
58
+ literal no longer exhausts memory.
59
+
60
+ ### Security
61
+
22
62
  ## [2.2.16] - 2026-11-27
23
63
 
24
64
  ### Added
@@ -568,7 +568,7 @@ dependencies = [
568
568
 
569
569
  [[package]]
570
570
  name = "jsonata-core"
571
- version = "2.2.16"
571
+ version = "2.2.17"
572
572
  dependencies = [
573
573
  "assert_cmd",
574
574
  "base64",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonata-core"
3
- version = "2.2.16"
3
+ version = "2.2.17"
4
4
  edition = "2021"
5
5
  authors = ["txjmb <txjmb@users.noreply.github.com>"]
6
6
  description = "High-performance Rust implementation of JSONata query and transformation language"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jsonatapy
3
- Version: 2.2.16
3
+ Version: 2.2.17
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -75,7 +75,7 @@ Project-URL: Repository, https://github.com/txjmb/jsonata-core
75
75
  <source media="(prefers-color-scheme: dark)"
76
76
  srcset="https://raw.githubusercontent.com/txjmb/jsonata-core/main/docs/assets/realistic-workload-dark.svg">
77
77
  <img width="880"
78
- alt="Realistic-workload benchmark on a 100-product dataset, lower is better: jsonatapy is 8.1x faster than the jsonata-js reference on the geometric mean of 5 e-commerce queries, and the pure-Rust jsonata-core engine is faster still."
78
+ alt="Realistic-workload benchmark on a 100-product dataset, lower is better: jsonatapy is 7.9x faster than the jsonata-js reference on the geometric mean of 5 e-commerce queries, and the pure-Rust jsonata-core engine is faster still."
79
79
  src="https://raw.githubusercontent.com/txjmb/jsonata-core/main/docs/assets/realistic-workload-light.svg">
80
80
  </picture>
81
81
  </a>
@@ -156,10 +156,10 @@ let result = Evaluator::new().evaluate(&ast, &data)?;
156
156
  ```toml
157
157
  # Cargo.toml
158
158
  [dependencies]
159
- jsonata-core = "2.2.16" # pure Rust, no Python dependency
159
+ jsonata-core = "2.2.17" # pure Rust, no Python dependency
160
160
 
161
161
  # Optional: disable SIMD for constrained targets
162
- jsonata-core = { version = "2.2.16", default-features = false }
162
+ jsonata-core = { version = "2.2.17", default-features = false }
163
163
  ```
164
164
 
165
165
  ---
@@ -26,7 +26,7 @@
26
26
  <source media="(prefers-color-scheme: dark)"
27
27
  srcset="https://raw.githubusercontent.com/txjmb/jsonata-core/main/docs/assets/realistic-workload-dark.svg">
28
28
  <img width="880"
29
- alt="Realistic-workload benchmark on a 100-product dataset, lower is better: jsonatapy is 8.1x faster than the jsonata-js reference on the geometric mean of 5 e-commerce queries, and the pure-Rust jsonata-core engine is faster still."
29
+ alt="Realistic-workload benchmark on a 100-product dataset, lower is better: jsonatapy is 7.9x faster than the jsonata-js reference on the geometric mean of 5 e-commerce queries, and the pure-Rust jsonata-core engine is faster still."
30
30
  src="https://raw.githubusercontent.com/txjmb/jsonata-core/main/docs/assets/realistic-workload-light.svg">
31
31
  </picture>
32
32
  </a>
@@ -107,10 +107,10 @@ let result = Evaluator::new().evaluate(&ast, &data)?;
107
107
  ```toml
108
108
  # Cargo.toml
109
109
  [dependencies]
110
- jsonata-core = "2.2.16" # pure Rust, no Python dependency
110
+ jsonata-core = "2.2.17" # pure Rust, no Python dependency
111
111
 
112
112
  # Optional: disable SIMD for constrained targets
113
- jsonata-core = { version = "2.2.16", default-features = false }
113
+ jsonata-core = { version = "2.2.17", default-features = false }
114
114
  ```
115
115
 
116
116
  ---
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "jsonatapy"
7
- version = "2.2.16"
7
+ version = "2.2.17"
8
8
  description = "High-performance Python/Rust implementation of JSONata query and transformation language"
9
9
  authors = [
10
10
  {name = "txjmb", email = "txjmb@users.noreply.github.com"}
@@ -705,8 +705,12 @@ pub(crate) fn dispatch_pure_with(
705
705
  // is therefore NaN too. `NaN > 0` is false, so the reference
706
706
  // skips padding entirely and returns the string unchanged --
707
707
  // whatever pad character was given.
708
+ //
709
+ // The width is kept as an f64 (truncated, as `Math.trunc` does)
710
+ // so a huge width is not silently saturated by an integer cast
711
+ // before the D2016 size check below.
708
712
  let width = match &args.get(1) {
709
- Some(JValue::Number(n)) => *n as i32,
713
+ Some(JValue::Number(n)) => n.trunc(),
710
714
  Some(JValue::Undefined) | None => return Ok(JValue::string(string)),
711
715
  _ => {
712
716
  return Err(EvaluatorError::TypeError(
@@ -721,16 +725,31 @@ pub(crate) fn dispatch_pure_with(
721
725
  _ => Rc::from(" "),
722
726
  };
723
727
 
724
- let abs_width = width.unsigned_abs() as usize;
725
728
  // Count Unicode characters (code points), not bytes
726
729
  let char_count = string.chars().count();
730
+ let pad_length = width.abs() - char_count as f64;
727
731
 
728
- if char_count >= abs_width {
732
+ // NaN (from a NaN width) compares false here too, matching
733
+ // jsonata-js, which then returns the string unchanged.
734
+ if pad_length.is_nan() || pad_length <= 0.0 {
729
735
  // String is already long enough
730
736
  return Ok(JValue::string(string));
731
737
  }
732
738
 
733
- let padding_needed = abs_width - char_count;
739
+ // jsonata-js 2.3.0 (#832) caps the padding at ten million
740
+ // characters, the same limit as the range operator (D2014).
741
+ if pad_length > 1e7 {
742
+ return Err(EvaluatorError::EvaluationError(format!(
743
+ "D2016: The size of the string requested by the $pad function must not exceed 1e7. Attempted to allocate {}.",
744
+ if pad_length.is_finite() {
745
+ crate::value::js_number_to_string(pad_length)
746
+ } else {
747
+ "Infinity".to_string()
748
+ }
749
+ )));
750
+ }
751
+
752
+ let padding_needed = pad_length as usize;
734
753
 
735
754
  let pad_chars: Vec<char> = pad_string.chars().collect();
736
755
  let mut padding = String::with_capacity(padding_needed);
@@ -738,7 +757,7 @@ pub(crate) fn dispatch_pure_with(
738
757
  padding.push(pad_chars[i % pad_chars.len()]);
739
758
  }
740
759
 
741
- let result = if width < 0 {
760
+ let result = if width < 0.0 {
742
761
  // Left pad (negative width)
743
762
  format!("{}{}", padding, string)
744
763
  } else {
@@ -534,6 +534,11 @@ const ROMAN_NUMERALS: [(i64, &str); 13] = [
534
534
  (1, "i"),
535
535
  ];
536
536
 
537
+ /// The largest number formatted in roman numerals (jsonata-js 2.3.0
538
+ /// `maxRoman`): ten thousand Ms. §4.6.1 allows an upper bound, and larger
539
+ /// numbers use the format token `1`.
540
+ const MAX_ROMAN: f64 = 1e7;
541
+
537
542
  fn decimal_to_roman(mut value: i64) -> String {
538
543
  let mut result = String::new();
539
544
  for &(v, s) in ROMAN_NUMERALS.iter() {
@@ -832,6 +837,13 @@ fn format_integer_value(value: f64, format: &IntegerFormat) -> Result<String, Da
832
837
  'a'
833
838
  },
834
839
  ),
840
+ // There is no numeral larger than M, so a large number would be a
841
+ // long run of them (1e15 is 1e12 Ms). Like jsonata-js 2.3.0, numbers
842
+ // above ten thousand Ms are formatted as plain decimal digits.
843
+ // f64's Display prints integers without an exponent and with the
844
+ // shortest round-trip digits, as jsonata-js's decimal digits do, so
845
+ // this is right above i64 too (unlike the Decimal arm, #864).
846
+ PrimaryFormat::Roman if value > MAX_ROMAN => format!("{}", value.trunc()),
835
847
  PrimaryFormat::Roman => {
836
848
  let r = decimal_to_roman(value as i64);
837
849
  if format.case == TCase::Upper {
@@ -975,6 +987,10 @@ fn add_literal(spec: &mut Vec<PictureItem>, lit: &str) {
975
987
  }
976
988
  }
977
989
 
990
+ /// The largest width modifier allowed in a date/time picture string
991
+ /// (jsonata-js 2.3.0 `maxWidthModifier`, error D3142).
992
+ const MAX_WIDTH_MODIFIER: usize = 100;
993
+
978
994
  /// Analyse a date/time picture string (§9.8.4.1).
979
995
  fn analyse_date_time_picture(picture: &str) -> Result<Vec<PictureItem>, DateTimeError> {
980
996
  let chars: Vec<char> = picture.chars().collect();
@@ -1014,19 +1030,33 @@ fn analyse_date_time_picture(picture: &str) -> Result<Vec<PictureItem>, DateTime
1014
1030
  let (pres_mod, width) = if let Some(comma_idx) = comma {
1015
1031
  let width_mod = &marker[comma_idx + 1..];
1016
1032
  let dash = width_mod.find('-');
1017
- let parse_width = |s: &str| -> Option<usize> {
1033
+ let parse_width = |s: &str| -> Result<Option<usize>, DateTimeError> {
1018
1034
  if s.is_empty() || s == "*" {
1019
- None
1035
+ Ok(None)
1020
1036
  } else {
1021
- s.parse().ok()
1037
+ // jsonata-js 2.3.0 rejects a width modifier above 100
1038
+ // (D3142): a component is padded to its minimum width,
1039
+ // so a huge width would build a huge string (or, for
1040
+ // `Y`, overflow `10^n`). The test uses JS `parseInt`,
1041
+ // so a value too large for usize is still caught.
1042
+ if js_parse_int(s) > MAX_WIDTH_MODIFIER as f64 {
1043
+ return Err(coded(
1044
+ "D3142",
1045
+ format!(
1046
+ "A width modifier in a date/time picture string cannot be greater than 100: \"{}\"",
1047
+ s
1048
+ ),
1049
+ ));
1050
+ }
1051
+ Ok(s.parse().ok())
1022
1052
  }
1023
1053
  };
1024
1054
  let (min, max) = match dash {
1025
1055
  Some(d) => (
1026
- parse_width(&width_mod[..d]),
1027
- parse_width(&width_mod[d + 1..]),
1056
+ parse_width(&width_mod[..d])?,
1057
+ parse_width(&width_mod[d + 1..])?,
1028
1058
  ),
1029
- None => (parse_width(width_mod), None),
1059
+ None => (parse_width(width_mod)?, None),
1030
1060
  };
1031
1061
  (
1032
1062
  marker[1..comma_idx].to_string(),
@@ -1408,7 +1438,12 @@ fn format_component(
1408
1438
  let mut value = get_date_time_fragment(local_millis, marker.component);
1409
1439
  if marker.component == 'Y' {
1410
1440
  if let Some(n) = marker.n {
1411
- value %= 10i64.pow(n);
1441
+ // `10^n` overflows i64 from n = 19, when every i64 year is
1442
+ // already below it, so the modulus is then a no-op (as
1443
+ // `value % Math.pow(10, n)` is in JS).
1444
+ if let Some(modulus) = 10i64.checked_pow(n) {
1445
+ value %= modulus;
1446
+ }
1412
1447
  }
1413
1448
  }
1414
1449
  if let Some(case) = marker.names {
@@ -1440,10 +1475,13 @@ fn format_component(
1440
1475
  } else if marker.component == 'f' {
1441
1476
  // §9.8.4.5 Formatting Fractional Seconds
1442
1477
  let value = get_date_time_fragment(local_millis, 'f');
1478
+ // A name presentation (`[fN]`) leaves no integer format: fractional
1479
+ // seconds can't be formatted as a name (D3133, as in jsonata-js
1480
+ // 2.3.0) -- this used to panic.
1443
1481
  let fmt = marker
1444
1482
  .integer_format
1445
1483
  .as_ref()
1446
- .expect("f marker always has an integer_format");
1484
+ .ok_or_else(|| coded("D3133", "f"))?;
1447
1485
  format_integer_value(value as f64, fmt)
1448
1486
  } else {
1449
1487
  // C (calendar) / E (era) -- always "ISO"
@@ -1611,7 +1649,18 @@ fn decimal_digits(fmt: &IntegerFormat, captured: &str) -> String {
1611
1649
  if fmt.zero_code != 0x30 {
1612
1650
  digits = digits
1613
1651
  .chars()
1614
- .map(|c| char::from_u32(c as u32 - fmt.zero_code + 0x30).unwrap())
1652
+ // Only digits of the picture's own family are mapped to ASCII;
1653
+ // anything else (an ASCII digit, say) is left alone instead of
1654
+ // underflowing into an invalid code point (as jsonata-js 2.3.0's
1655
+ // `toAsciiDigits` does).
1656
+ .map(|c| {
1657
+ let code = c as u32;
1658
+ if (fmt.zero_code..=fmt.zero_code + 9).contains(&code) {
1659
+ char::from_u32(code - fmt.zero_code + 0x30).unwrap_or(c)
1660
+ } else {
1661
+ c
1662
+ }
1663
+ })
1615
1664
  .collect();
1616
1665
  }
1617
1666
  digits
@@ -1821,11 +1870,35 @@ fn parse_component_value(
1821
1870
  }
1822
1871
  }
1823
1872
 
1873
+ /// The largest match (picture parts times timestamp positions) attempted
1874
+ /// when parsing a timestamp (jsonata-js 2.3.0 `maxMatchSize`).
1875
+ const MAX_MATCH_SIZE: usize = 1_000_000;
1876
+
1824
1877
  /// Parses a string containing a timestamp as specified by a date/time picture string
1825
1878
  /// (mirrors datetime.js's `parseDateTime`). Returns `Ok(None)` (meaning "undefined") if
1826
1879
  /// the timestamp doesn't match the picture, or if the picture has no markers at all.
1827
1880
  fn parse_date_time(timestamp: &str, picture: &str, now: i64) -> Result<Option<f64>, DateTimeError> {
1828
1881
  let spec = analyse_date_time_picture(picture)?;
1882
+
1883
+ // Guard from jsonata-js 2.3.0 (`analyseDateTimePicture`'s `cannotMatch`):
1884
+ // a timestamp needs every character of each literal and at least one per
1885
+ // marker, and matching costs time and memory proportional to the number
1886
+ // of picture parts times the timestamp length. A timestamp that is too
1887
+ // short, or a match that would be too large, cannot match -- return
1888
+ // undefined instead of compiling a regex that can exhaust memory. The
1889
+ // picture is analysed first, so an invalid one is still an error.
1890
+ let max_length = timestamp.chars().count();
1891
+ let min_length: usize = spec
1892
+ .iter()
1893
+ .map(|item| match item {
1894
+ PictureItem::Literal(lit) => lit.chars().count(),
1895
+ PictureItem::Marker(_) => 1,
1896
+ })
1897
+ .sum();
1898
+ if min_length > max_length || spec.len().saturating_mul(max_length + 1) > MAX_MATCH_SIZE {
1899
+ return Ok(None);
1900
+ }
1901
+
1829
1902
  let parts = build_matcher_parts(&spec)?;
1830
1903
 
1831
1904
  let pattern = format!(
@@ -2040,6 +2113,100 @@ fn date_utc(
2040
2113
  mod tests {
2041
2114
  use super::*;
2042
2115
 
2116
+ /// The code of a coded datetime error, for the 2.2.17 guard tests.
2117
+ fn error_code(result: Result<JValue, DateTimeError>) -> &'static str {
2118
+ match result {
2119
+ Err(DateTimeError::Coded { code, .. }) => code,
2120
+ other => panic!("expected a coded error, got {other:?}"),
2121
+ }
2122
+ }
2123
+
2124
+ #[test]
2125
+ fn width_modifier_over_100_is_d3142() {
2126
+ for picture in [
2127
+ "[Y,101]",
2128
+ "[Y,600000000]",
2129
+ "[f,150000000]",
2130
+ "[Y,2-101]",
2131
+ "[D,99999999999999999999]",
2132
+ ] {
2133
+ assert_eq!(
2134
+ error_code(from_millis_with_picture(0.0, Some(picture), None)),
2135
+ "D3142",
2136
+ "{picture}"
2137
+ );
2138
+ }
2139
+ assert_eq!(
2140
+ error_code(to_millis_with_picture("1970", "[Y,101]")),
2141
+ "D3142"
2142
+ );
2143
+ }
2144
+
2145
+ #[test]
2146
+ fn width_modifier_of_100_does_not_overflow_the_year_modulus() {
2147
+ let formatted = from_millis_with_picture(0.0, Some("[Y,100]"), None).unwrap();
2148
+ assert_eq!(formatted, JValue::string(format!("{}1970", "0".repeat(96))));
2149
+ }
2150
+
2151
+ #[test]
2152
+ fn roman_numerals_above_1e7_are_decimal() {
2153
+ assert_eq!(
2154
+ format_integer(1e8, "I").unwrap(),
2155
+ JValue::string("100000000")
2156
+ );
2157
+ assert_eq!(
2158
+ format_integer(-1e15, "i").unwrap(),
2159
+ JValue::string("-1000000000000000")
2160
+ );
2161
+ assert_eq!(
2162
+ format_integer(1e20, "I").unwrap(),
2163
+ JValue::string("100000000000000000000")
2164
+ );
2165
+ assert_eq!(
2166
+ format_integer(1999.0, "I").unwrap(),
2167
+ JValue::string("MCMXCIX")
2168
+ );
2169
+ }
2170
+
2171
+ #[test]
2172
+ fn digits_outside_the_picture_family_do_not_panic() {
2173
+ assert_eq!(
2174
+ parse_integer("12", "\u{661}").unwrap(),
2175
+ JValue::Number(12.0)
2176
+ );
2177
+ assert_eq!(
2178
+ parse_integer("\u{661}\u{662}", "\u{661}").unwrap(),
2179
+ JValue::Number(12.0)
2180
+ );
2181
+ }
2182
+
2183
+ #[test]
2184
+ fn fractional_seconds_as_a_name_is_d3133() {
2185
+ assert_eq!(
2186
+ error_code(from_millis_with_picture(0.0, Some("[fN]"), None)),
2187
+ "D3133"
2188
+ );
2189
+ }
2190
+
2191
+ #[test]
2192
+ fn unmatchable_timestamps_are_undefined_without_matching() {
2193
+ let markers = "[Y]1".repeat(100_000);
2194
+ let timestamp = format!("{}x", "1".repeat(99_999));
2195
+ assert_eq!(
2196
+ to_millis_with_picture(&timestamp, &markers).unwrap(),
2197
+ JValue::Undefined
2198
+ );
2199
+ let literal = "a".repeat(10_000_000);
2200
+ assert_eq!(
2201
+ to_millis_with_picture("x", &literal).unwrap(),
2202
+ JValue::Undefined
2203
+ );
2204
+ assert_eq!(
2205
+ to_millis_with_picture("1", "[Y][M]").unwrap(),
2206
+ JValue::Undefined
2207
+ );
2208
+ }
2209
+
2043
2210
  /// The date `year`-`month`-`day`, or `None` if there is no such day.
2044
2211
  fn from_ymd(year: i64, month: i64, day: i64) -> Option<CivilDate> {
2045
2212
  let days_in_month = match month {