@budibase/backend-core 2.30.8 → 2.31.1
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 +33 -10
- package/dist/index.js.map +3 -3
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/src/sql/sql.js +12 -10
- package/dist/src/sql/sql.js.map +1 -1
- package/package.json +4 -4
- package/src/sql/sql.ts +15 -10
package/dist/index.js
CHANGED
|
@@ -54483,6 +54483,11 @@ var RangeOperator = /* @__PURE__ */ ((RangeOperator2) => {
|
|
|
54483
54483
|
RangeOperator2["RANGE"] = "range";
|
|
54484
54484
|
return RangeOperator2;
|
|
54485
54485
|
})(RangeOperator || {});
|
|
54486
|
+
var LogicalOperator = /* @__PURE__ */ ((LogicalOperator2) => {
|
|
54487
|
+
LogicalOperator2["AND"] = "$and";
|
|
54488
|
+
LogicalOperator2["OR"] = "$or";
|
|
54489
|
+
return LogicalOperator2;
|
|
54490
|
+
})(LogicalOperator || {});
|
|
54486
54491
|
function isLogicalSearchOperator(value) {
|
|
54487
54492
|
return value === "$and" /* AND */ || value === "$or" /* OR */;
|
|
54488
54493
|
}
|
|
@@ -54864,6 +54869,7 @@ __export(filters_exports, {
|
|
|
54864
54869
|
getValidOperatorsForType: () => getValidOperatorsForType,
|
|
54865
54870
|
hasFilters: () => hasFilters,
|
|
54866
54871
|
limit: () => limit,
|
|
54872
|
+
recurseLogicalOperators: () => recurseLogicalOperators,
|
|
54867
54873
|
removeKeyNumbering: () => removeKeyNumbering,
|
|
54868
54874
|
runQuery: () => runQuery,
|
|
54869
54875
|
search: () => search,
|
|
@@ -55093,6 +55099,16 @@ var NoEmptyFilterStrings = [
|
|
|
55093
55099
|
OperatorOptions.ContainsAny.value,
|
|
55094
55100
|
OperatorOptions.In.value
|
|
55095
55101
|
];
|
|
55102
|
+
function recurseLogicalOperators(filters, fn) {
|
|
55103
|
+
for (const logical of Object.values(LogicalOperator)) {
|
|
55104
|
+
if (filters[logical]) {
|
|
55105
|
+
filters[logical].conditions = filters[logical].conditions.map(
|
|
55106
|
+
(condition) => fn(condition)
|
|
55107
|
+
);
|
|
55108
|
+
}
|
|
55109
|
+
}
|
|
55110
|
+
return filters;
|
|
55111
|
+
}
|
|
55096
55112
|
var cleanupQuery = (query) => {
|
|
55097
55113
|
if (!query) {
|
|
55098
55114
|
return query;
|
|
@@ -55115,6 +55131,7 @@ var cleanupQuery = (query) => {
|
|
|
55115
55131
|
}
|
|
55116
55132
|
}
|
|
55117
55133
|
}
|
|
55134
|
+
query = recurseLogicalOperators(query, cleanupQuery);
|
|
55118
55135
|
return query;
|
|
55119
55136
|
};
|
|
55120
55137
|
function isEmptyArray(value) {
|
|
@@ -55297,6 +55314,7 @@ function fixupFilterArrays(filters) {
|
|
|
55297
55314
|
}
|
|
55298
55315
|
}
|
|
55299
55316
|
}
|
|
55317
|
+
recurseLogicalOperators(filters, fixupFilterArrays);
|
|
55300
55318
|
return filters;
|
|
55301
55319
|
}
|
|
55302
55320
|
var search = (docs, query) => {
|
|
@@ -67912,6 +67930,7 @@ var SqlTableQueryBuilder = class {
|
|
|
67912
67930
|
var sqlTable_default = SqlTableQueryBuilder;
|
|
67913
67931
|
|
|
67914
67932
|
// src/sql/sql.ts
|
|
67933
|
+
var import_lodash3 = require("lodash");
|
|
67915
67934
|
function getBaseLimit() {
|
|
67916
67935
|
const envLimit = environment_default.SQL_MAX_ROWS ? parseInt(environment_default.SQL_MAX_ROWS) : null;
|
|
67917
67936
|
return envLimit || 5e3;
|
|
@@ -68071,6 +68090,7 @@ var InternalBuilder = class {
|
|
|
68071
68090
|
return body2;
|
|
68072
68091
|
}
|
|
68073
68092
|
parseFilters(filters) {
|
|
68093
|
+
filters = (0, import_lodash3.cloneDeep)(filters);
|
|
68074
68094
|
for (const op of Object.values(BasicOperator)) {
|
|
68075
68095
|
const filter = filters[op];
|
|
68076
68096
|
if (!filter) {
|
|
@@ -68130,7 +68150,7 @@ var InternalBuilder = class {
|
|
|
68130
68150
|
if (!filters) {
|
|
68131
68151
|
return query;
|
|
68132
68152
|
}
|
|
68133
|
-
filters = this.parseFilters(filters);
|
|
68153
|
+
filters = this.parseFilters({ ...filters });
|
|
68134
68154
|
const aliases = this.query.tableAliases;
|
|
68135
68155
|
const allOr = filters.allOr;
|
|
68136
68156
|
const tableName = this.client === "sqlite3" /* SQL_LITE */ ? this.table._id : this.table.name;
|
|
@@ -68152,10 +68172,11 @@ var InternalBuilder = class {
|
|
|
68152
68172
|
),
|
|
68153
68173
|
castedTypeValue.values
|
|
68154
68174
|
);
|
|
68155
|
-
} else if (!
|
|
68175
|
+
} else if (!isRelationshipField) {
|
|
68156
68176
|
const alias = getTableAlias(tableName);
|
|
68157
68177
|
fn(alias ? `${alias}.${updatedKey}` : updatedKey, value);
|
|
68158
|
-
}
|
|
68178
|
+
}
|
|
68179
|
+
if (opts?.relationship && isRelationshipField) {
|
|
68159
68180
|
const [filterTableName, property] = updatedKey.split(".");
|
|
68160
68181
|
const alias = getTableAlias(filterTableName);
|
|
68161
68182
|
fn(alias ? `${alias}.${property}` : property, value);
|
|
@@ -68237,17 +68258,19 @@ var InternalBuilder = class {
|
|
|
68237
68258
|
};
|
|
68238
68259
|
if (filters.$and) {
|
|
68239
68260
|
const { $and } = filters;
|
|
68240
|
-
|
|
68241
|
-
|
|
68242
|
-
|
|
68243
|
-
}
|
|
68244
|
-
}
|
|
68261
|
+
for (const condition of $and.conditions) {
|
|
68262
|
+
query = query.where((b) => {
|
|
68263
|
+
this.addFilters(b, condition, opts);
|
|
68264
|
+
});
|
|
68265
|
+
}
|
|
68245
68266
|
}
|
|
68246
68267
|
if (filters.$or) {
|
|
68247
68268
|
const { $or } = filters;
|
|
68248
|
-
query = query.where((
|
|
68269
|
+
query = query.where((b) => {
|
|
68249
68270
|
for (const condition of $or.conditions) {
|
|
68250
|
-
|
|
68271
|
+
b.orWhere(
|
|
68272
|
+
(c) => this.addFilters(c, { ...condition, allOr: true }, opts)
|
|
68273
|
+
);
|
|
68251
68274
|
}
|
|
68252
68275
|
});
|
|
68253
68276
|
}
|