@budibase/backend-core 2.9.26-alpha.3 → 2.9.26-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4060,6 +4060,7 @@ var init_lucene = __esm({
4060
4060
  "use strict";
4061
4061
  import_node_fetch2 = __toESM(require("node-fetch"));
4062
4062
  init_couch();
4063
+ init_src();
4063
4064
  QUERY_START_REGEX = /\d[0-9]*:/g;
4064
4065
  QueryBuilder = class _QueryBuilder {
4065
4066
  #dbName;
@@ -4083,6 +4084,7 @@ var init_lucene = __esm({
4083
4084
  this.#index = index2;
4084
4085
  this.#query = {
4085
4086
  allOr: false,
4087
+ onEmptyFilter: "all" /* RETURN_ALL */,
4086
4088
  string: {},
4087
4089
  fuzzy: {},
4088
4090
  range: {},
@@ -4211,6 +4213,9 @@ var init_lucene = __esm({
4211
4213
  setAllOr() {
4212
4214
  this.#query.allOr = true;
4213
4215
  }
4216
+ setOnEmptyFilter(value) {
4217
+ this.#query.onEmptyFilter = value;
4218
+ }
4214
4219
  handleSpaces(input) {
4215
4220
  if (this.#noEscaping) {
4216
4221
  return input;
@@ -4271,8 +4276,9 @@ var init_lucene = __esm({
4271
4276
  const builder = this;
4272
4277
  let allOr = this.#query && this.#query.allOr;
4273
4278
  let query = allOr ? "" : "*:*";
4279
+ let allFiltersEmpty = true;
4274
4280
  const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
4275
- let tableId;
4281
+ let tableId = "";
4276
4282
  if (this.#query.equal.tableId) {
4277
4283
  tableId = this.#query.equal.tableId;
4278
4284
  delete this.#query.equal.tableId;
@@ -4284,7 +4290,7 @@ var init_lucene = __esm({
4284
4290
  return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
4285
4291
  };
4286
4292
  const contains = (key, value, mode = "AND") => {
4287
- if (Array.isArray(value) && value.length === 0) {
4293
+ if (!value || Array.isArray(value) && value.length === 0) {
4288
4294
  return null;
4289
4295
  }
4290
4296
  if (!Array.isArray(value)) {
@@ -4353,6 +4359,9 @@ var init_lucene = __esm({
4353
4359
  built += ` ${mode} `;
4354
4360
  }
4355
4361
  built += expression;
4362
+ if (typeof value !== "string" && value != null || typeof value === "string" && value !== tableId && value !== "") {
4363
+ allFiltersEmpty = false;
4364
+ }
4356
4365
  }
4357
4366
  if (opts?.returnBuilt) {
4358
4367
  return built;
@@ -4429,6 +4438,13 @@ var init_lucene = __esm({
4429
4438
  allOr = false;
4430
4439
  build({ tableId }, equal);
4431
4440
  }
4441
+ if (allFiltersEmpty) {
4442
+ if (this.#query.onEmptyFilter === "none" /* RETURN_NONE */) {
4443
+ return "";
4444
+ } else if (this.#query?.allOr) {
4445
+ return query.replace("()", "(*:*)");
4446
+ }
4447
+ }
4432
4448
  return query;
4433
4449
  }
4434
4450
  buildSearchBody() {