Skip to content

Commit

Permalink
Fixed EXISTS function in subqueries and SET operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Midwayne committed Jun 28, 2024
1 parent ca7ecb4 commit 1c5092a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/41exists.js
Original file line number Diff line number Diff line change
@@ -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
//
*/

Expand All @@ -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;
Expand Down

0 comments on commit 1c5092a

Please sign in to comment.