@budibase/frontend-core 2.2.3 → 2.2.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/utils/lucene.js +23 -10
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
7
7
  "svelte": "src/index.js",
8
8
  "dependencies": {
9
- "@budibase/bbui": "^2.2.3",
9
+ "@budibase/bbui": "^2.2.4",
10
10
  "lodash": "^4.17.21",
11
11
  "svelte": "^3.46.2"
12
12
  },
13
- "gitHead": "1fee98510b81d27546acc7fa1dbcfb89784c8802"
13
+ "gitHead": "f1dea09042fb0ca40c29976ceeaab2ca740ee424"
14
14
  }
@@ -7,7 +7,7 @@ const HBS_REGEX = /{{([^{].*?)}}/g
7
7
  * Returns the valid operator options for a certain data type
8
8
  * @param type the data type
9
9
  */
10
- export const getValidOperatorsForType = type => {
10
+ export const getValidOperatorsForType = (type, field, datasource) => {
11
11
  const Op = OperatorOptions
12
12
  const stringOps = [
13
13
  Op.Equals,
@@ -27,24 +27,37 @@ export const getValidOperatorsForType = type => {
27
27
  Op.NotEmpty,
28
28
  Op.In,
29
29
  ]
30
+ let ops = []
30
31
  if (type === "string") {
31
- return stringOps
32
+ ops = stringOps
32
33
  } else if (type === "number") {
33
- return numOps
34
+ ops = numOps
34
35
  } else if (type === "options") {
35
- return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
36
+ ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
36
37
  } else if (type === "array") {
37
- return [Op.Contains, Op.NotContains, Op.Empty, Op.NotEmpty, Op.ContainsAny]
38
+ ops = [Op.Contains, Op.NotContains, Op.Empty, Op.NotEmpty, Op.ContainsAny]
38
39
  } else if (type === "boolean") {
39
- return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty]
40
+ ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty]
40
41
  } else if (type === "longform") {
41
- return stringOps
42
+ ops = stringOps
42
43
  } else if (type === "datetime") {
43
- return numOps
44
+ ops = numOps
44
45
  } else if (type === "formula") {
45
- return stringOps.concat([Op.MoreThan, Op.LessThan])
46
+ ops = stringOps.concat([Op.MoreThan, Op.LessThan])
46
47
  }
47
- return []
48
+
49
+ // Filter out "like" for internal tables
50
+ const externalTable = datasource?.tableId?.includes("datasource_plus")
51
+ if (datasource?.type === "table" && !externalTable) {
52
+ ops = ops.filter(x => x !== Op.Like)
53
+ }
54
+
55
+ // Only allow equal/not equal for _id in SQL tables
56
+ if (field === "_id" && externalTable) {
57
+ ops = [Op.Equals, Op.NotEquals]
58
+ }
59
+
60
+ return ops
48
61
  }
49
62
 
50
63
  /**