From aeb3b00c926dcc7e7ea7c7e15c95323261c66f5d Mon Sep 17 00:00:00 2001 From: Kushal Krishna Date: Tue, 9 Jul 2024 03:04:28 +0530 Subject: [PATCH] Support EXISTS Function for Subqueries to fix #1904 (#1939) --- src/41exists.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/41exists.js b/src/41exists.js index 0a934af412..bd7cf8beb6 100755 --- a/src/41exists.js +++ b/src/41exists.js @@ -1,8 +1,9 @@ /* // -// EXISTS and other subqueries functions functions for Alasql.js +// EXISTS and other subqueries functions for AlaSQL.js // Date: 03.11.2014 // (c) 2014, Andrey Gershun +// Modified by: Midwayne // */ @@ -20,12 +21,13 @@ yy.ExistsValue = class ExistsValue { } toJS(context, tableid, defcols) { - return `this.existsfn[${this.existsidx}](params, null, ${context}).data.length`; + // Updated to return a boolean value correctly + return `!!this.existsfn[${this.existsidx}](params, null, ${context}).data.length`; } }; // -// Prepare subqueries and exists +// Prepare subqueries and EXISTS // alasql.precompile = function (statement, databaseid, params) { if (!statement) return;