From 886534da1bbb0b2cf74ba3d016eaadae2c2a2e48 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Fri, 15 Nov 2024 13:54:47 +0100 Subject: [PATCH] fix lambdas --- hogvm/__tests__/__snapshots__/lambdas.js | 2 +- posthog/hogql/compiler/javascript_stl.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hogvm/__tests__/__snapshots__/lambdas.js b/hogvm/__tests__/__snapshots__/lambdas.js index 0560b6d65d4fd..1e2719b7cbbd4 100644 --- a/hogvm/__tests__/__snapshots__/lambdas.js +++ b/hogvm/__tests__/__snapshots__/lambdas.js @@ -25,7 +25,7 @@ function jsonStringify (value, spacing) { if (spacing && typeof spacing === 'number' && spacing > 0) { return JSON.stringify(convert(value), null, spacing) } - return JSON.stringify(convert(value)) + return JSON.stringify(convert(value), (key, val) => typeof val === 'function' ? `fn<${val.name || 'lambda'}(${val.length})>` : val) } function jsonParse (str) { function convert(x) { diff --git a/posthog/hogql/compiler/javascript_stl.py b/posthog/hogql/compiler/javascript_stl.py index bd42f46bac525..aea89033b0a96 100644 --- a/posthog/hogql/compiler/javascript_stl.py +++ b/posthog/hogql/compiler/javascript_stl.py @@ -128,7 +128,7 @@ if (spacing && typeof spacing === 'number' && spacing > 0) { return JSON.stringify(convert(value), null, spacing) } - return JSON.stringify(convert(value)) + return JSON.stringify(convert(value), (key, val) => typeof val === 'function' ? `fn<${val.name || 'lambda'}(${val.length})>` : val) }""", ["__isHogDateTime", "__isHogDate", "__isHogError"], ],