From f73d90915762f0af37efbb33a0676f72ad2103a1 Mon Sep 17 00:00:00 2001 From: Aston Monteiro <152646326+Aston8@users.noreply.github.com> Date: Sun, 19 Apr 2026 23:07:41 +0530 Subject: [PATCH] Refactor MAX and MIN functions to handle null values --- src/55functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/55functions.js b/src/55functions.js index 9bdc42ff24..bad0db9e1b 100644 --- a/src/55functions.js +++ b/src/55functions.js @@ -170,7 +170,7 @@ stdlib.MAX = stdlib.GREATEST = function () { return ( '[' + Array.prototype.join.call(arguments, ',') + - '].reduce(function (a, b) { return a > b ? a : b; })' + '].reduce(function (a, b) { ' + 'if(a==null) return b; ' + 'if(b==null) return a; ' + ' return new Date(a).getTime() < new Date(b).getTime() ? b : a; })' ); }; @@ -178,7 +178,7 @@ stdlib.MIN = stdlib.LEAST = function () { return ( '[' + Array.prototype.join.call(arguments, ',') + - '].reduce(function (a, b) { return a < b ? a : b; })' + '].reduce(function (a, b) { ' + 'if(a==null) return b; ' + 'if(b==null) return a; ' + ' return new Date(a).getTime() < new Date(b).getTime() ? a : b; })' ); };