@budibase/server 2.4.6 → 2.4.8-alpha.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.4.6",
4
+ "version": "2.4.8-alpha.0",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -43,11 +43,11 @@
43
43
  "license": "GPL-3.0",
44
44
  "dependencies": {
45
45
  "@apidevtools/swagger-parser": "10.0.3",
46
- "@budibase/backend-core": "^2.4.6",
47
- "@budibase/client": "^2.4.6",
48
- "@budibase/pro": "2.4.5",
49
- "@budibase/string-templates": "^2.4.6",
50
- "@budibase/types": "^2.4.6",
46
+ "@budibase/backend-core": "2.4.8-alpha.0",
47
+ "@budibase/client": "2.4.8-alpha.0",
48
+ "@budibase/pro": "2.4.6",
49
+ "@budibase/string-templates": "2.4.8-alpha.0",
50
+ "@budibase/types": "2.4.8-alpha.0",
51
51
  "@bull-board/api": "3.7.0",
52
52
  "@bull-board/koa": "3.9.4",
53
53
  "@elastic/elasticsearch": "7.10.0",
@@ -174,5 +174,5 @@
174
174
  "optionalDependencies": {
175
175
  "oracledb": "5.3.0"
176
176
  },
177
- "gitHead": "d8cc9b7c9c02501be59cf276f3772ebb5dfeb082"
177
+ "gitHead": "9094f6f1dd985556752a3d724b03302b9f5a345f"
178
178
  }
@@ -52,14 +52,18 @@ export function cleanInputValues(inputs: Record<string, any>, schema: any) {
52
52
  }
53
53
  }
54
54
  }
55
- //Check if input field should be a relationship and cast to array
55
+ //Check if input field for Update Row should be a relationship and cast to array
56
56
  for (let key in inputs.row) {
57
57
  if (
58
58
  inputs.schema?.[key]?.type === "link" &&
59
59
  inputs.row[key] &&
60
60
  typeof inputs.row[key] === "string"
61
61
  ) {
62
- inputs.row[key] = JSON.parse(inputs.row[key])
62
+ try {
63
+ inputs.row[key] = JSON.parse(inputs.row[key])
64
+ } catch (e) {
65
+ //Link is not an array or object, so continue
66
+ }
63
67
  }
64
68
  }
65
69
  return inputs
@@ -62,4 +62,72 @@ describe("automationUtils", () => {
62
62
  ).toThrow()
63
63
  })
64
64
  })
65
+
66
+ describe("cleanInputValues", () => {
67
+ it("should handle array relationship fields from read binding", () => {
68
+ const schema = {
69
+ relationship: {
70
+ type: "link",
71
+ constraints: {
72
+ type: "array",
73
+ presence: false,
74
+ },
75
+ fieldName: "Users",
76
+ name: "relationship",
77
+ relationshipType: "many-to-many",
78
+ tableId: "ta_users",
79
+ sortable: false,
80
+ },
81
+ }
82
+ expect(
83
+ automationUtils.cleanInputValues(
84
+ {
85
+ row: {
86
+ relationship: `[{"_id": "ro_ta_users_us_3"}]`,
87
+ },
88
+ schema,
89
+ },
90
+ schema
91
+ )
92
+ ).toEqual({
93
+ row: {
94
+ relationship: [{ _id: "ro_ta_users_us_3" }],
95
+ },
96
+ schema,
97
+ })
98
+ })
99
+
100
+ it("should handle single string relationship field", () => {
101
+ const schema = {
102
+ relationship: {
103
+ type: "link",
104
+ constraints: {
105
+ type: "array",
106
+ presence: false,
107
+ },
108
+ fieldName: "Users",
109
+ name: "relationship",
110
+ relationshipType: "many-to-many",
111
+ tableId: "ta_users",
112
+ sortable: false,
113
+ },
114
+ }
115
+ expect(
116
+ automationUtils.cleanInputValues(
117
+ {
118
+ row: {
119
+ relationship: `ro_ta_users_us_3`,
120
+ },
121
+ schema,
122
+ },
123
+ schema
124
+ )
125
+ ).toEqual({
126
+ row: {
127
+ relationship: "ro_ta_users_us_3",
128
+ },
129
+ schema,
130
+ })
131
+ })
132
+ })
65
133
  })