From 21e7ee999e0eadb197dedce65396151f98dc45cc Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 18 Jan 2022 07:37:13 -0500 Subject: [PATCH] Make is_null/is_not_null DSL functions include new JSON-null type --- internal/pkg/bifs/types.go | 4 ++-- internal/pkg/dsl/cst/builtin_function_manager.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/pkg/bifs/types.go b/internal/pkg/bifs/types.go index 54fe8d3a0..59cb9c178 100644 --- a/internal/pkg/bifs/types.go +++ b/internal/pkg/bifs/types.go @@ -194,10 +194,10 @@ func BIF_is_notarray(input1 *mlrval.Mlrval) *mlrval.Mlrval { return mlrval.FromBool(!input1.IsArray()) } func BIF_is_notnull(input1 *mlrval.Mlrval) *mlrval.Mlrval { - return mlrval.FromBool(!input1.IsAbsent() && !input1.IsVoid()) + return mlrval.FromBool(!input1.IsAbsent() && !input1.IsVoid() && !input1.IsNull()) } func BIF_is_null(input1 *mlrval.Mlrval) *mlrval.Mlrval { - return mlrval.FromBool(input1.IsAbsent() || input1.IsVoid()) + return mlrval.FromBool(input1.IsAbsent() || input1.IsVoid() || input1.IsNull()) } func BIF_is_numeric(input1 *mlrval.Mlrval) *mlrval.Mlrval { return mlrval.FromBool(input1.IsInt() || input1.IsFloat()) diff --git a/internal/pkg/dsl/cst/builtin_function_manager.go b/internal/pkg/dsl/cst/builtin_function_manager.go index ce8849a8e..2b37c0286 100644 --- a/internal/pkg/dsl/cst/builtin_function_manager.go +++ b/internal/pkg/dsl/cst/builtin_function_manager.go @@ -1203,14 +1203,14 @@ strftime_local.`, { name: "is_not_null", class: FUNC_CLASS_TYPING, - help: "False if argument is null (empty or absent), true otherwise.", + help: "False if argument is null (empty, absent, or JSON null), true otherwise.", unaryFunc: bifs.BIF_is_notnull, }, { name: "is_null", class: FUNC_CLASS_TYPING, - help: "True if argument is null (empty or absent), false otherwise.", + help: "True if argument is null (empty, absent, or JSON null), false otherwise.", unaryFunc: bifs.BIF_is_null, },