Skip to content

Commit da3806c

Browse files
l46kokcopybara-github
authored andcommitted
Enable cross-type numeric comparisons by default in CelOptions.current()
PiperOrigin-RevId: 1013327820
1 parent b25f765 commit da3806c

4 files changed

Lines changed: 6 additions & 10 deletions

File tree

‎PLANNER_MIGRATION_GUIDE.md‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@ Cel cel = CelFactory.plannerCelBuilder().build();
4141
> (`standardCelBuilder`, `legacyCelBuilder`, `standardCelRuntimeBuilder`,
4242
> `legacyCelRuntimeBuilder`) are deprecated.
4343
44-
If you are overriding `CelOptions`, ensure
45-
`enableHeterogeneousNumericComparisons` is enabled, and remove any deprecated
46-
options:
44+
If you are overriding `CelOptions`, start from `CelOptions.current()` and remove
45+
any deprecated options:
4746

4847
```java
4948
CelOptions options = CelOptions.current()
50-
// Ensure this is explicitly toggled on (enabled by default in planner
51-
// builders)
52-
.enableHeterogeneousNumericComparisons(true)
5349
// Remove the following deprecated options if you have them set:
5450
// .enableUnsignedLongs(...)
5551
// .unwrapWellKnownTypesOnFunctionDispatch(...)

‎bundle/src/main/java/dev/cel/bundle/CelFactory.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static CelBuilder plannerCelBuilder() {
7878
CelCheckerLegacyImpl.newBuilder().setStandardEnvironmentEnabled(true)),
7979
CelRuntimeImpl.newBuilder())
8080
// CEL-Internal-2
81-
.setOptions(CelOptions.current().enableHeterogeneousNumericComparisons(true).build());
81+
.setOptions(CelOptions.DEFAULT);
8282
}
8383

8484
/** Combines a prebuilt {@link CelCompiler} and {@link CelRuntime} into {@link Cel}. */

‎common/src/main/java/dev/cel/common/CelOptions.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public static Builder current() {
183183
.enableUnsignedLongs(true)
184184
.enableRegexPartialMatch(true)
185185
.enableTimestampEpoch(true)
186+
.enableHeterogeneousNumericComparisons(true)
186187
.errorOnDuplicateMapKeys(true)
187188
.evaluateCanonicalTypesToNativeValues(true)
188189
.errorOnIntWrap(true)
@@ -323,8 +324,7 @@ public abstract static class Builder {
323324
* Enable the {@code less_equals_double_int64} and other cross-type numeric comparisons for
324325
* {@code double}, {@code int64}, and {@code uint64} values.
325326
*
326-
* <p>This feature adds the declarations for these overloads to the CEL standard environment,
327-
* but the runtime functions are enabled by default.
327+
* <p>This option is enabled by default in {@link CelOptions#current}.
328328
*
329329
* <p>TODO: Remove this feature once it has been auto-enabled.
330330
*/

‎runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static CelRuntimeBuilder legacyCelRuntimeBuilder() {
6161
public static CelRuntimeBuilder plannerRuntimeBuilder() {
6262
return CelRuntimeImpl.newBuilder()
6363
// CEL-Internal-2
64-
.setOptions(CelOptions.current().enableHeterogeneousNumericComparisons(true).build());
64+
.setOptions(CelOptions.DEFAULT);
6565
}
6666

6767
private CelRuntimeFactory() {}

0 commit comments

Comments
 (0)