@budibase/server 2.7.15 → 2.7.17

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.7.15",
4
+ "version": "2.7.17",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -46,12 +46,12 @@
46
46
  "license": "GPL-3.0",
47
47
  "dependencies": {
48
48
  "@apidevtools/swagger-parser": "10.0.3",
49
- "@budibase/backend-core": "2.7.15",
50
- "@budibase/client": "2.7.15",
51
- "@budibase/pro": "2.7.15",
52
- "@budibase/shared-core": "2.7.15",
53
- "@budibase/string-templates": "2.7.15",
54
- "@budibase/types": "2.7.15",
49
+ "@budibase/backend-core": "2.7.17",
50
+ "@budibase/client": "2.7.17",
51
+ "@budibase/pro": "2.7.17",
52
+ "@budibase/shared-core": "2.7.17",
53
+ "@budibase/string-templates": "2.7.17",
54
+ "@budibase/types": "2.7.17",
55
55
  "@bull-board/api": "3.7.0",
56
56
  "@bull-board/koa": "3.9.4",
57
57
  "@elastic/elasticsearch": "7.10.0",
@@ -195,5 +195,5 @@
195
195
  }
196
196
  }
197
197
  },
198
- "gitHead": "0cd0299c3a6062d5a80220aecc4c96894e95519d"
198
+ "gitHead": "64940ff750340eb42345b602155e9c17c7ebf0b3"
199
199
  }
@@ -19,6 +19,7 @@ import {
19
19
  breakRowIdField,
20
20
  convertRowId,
21
21
  generateRowIdField,
22
+ getPrimaryDisplay,
22
23
  isRowId,
23
24
  isSQL,
24
25
  } from "../../../integrations/utils"
@@ -391,7 +392,10 @@ export class ExternalRequest {
391
392
  }
392
393
  }
393
394
  relatedRow = processFormulas(linkedTable, relatedRow)
394
- const relatedDisplay = display ? relatedRow[display] : undefined
395
+ let relatedDisplay
396
+ if (display) {
397
+ relatedDisplay = getPrimaryDisplay(relatedRow[display])
398
+ }
395
399
  row[relationship.column][key] = {
396
400
  primaryDisplay: relatedDisplay || "Invalid display column",
397
401
  _id: relatedRow._id,
@@ -91,7 +91,7 @@ const SCHEMA: Integration = {
91
91
  },
92
92
  }
93
93
 
94
- function bindingTypeCoerce(bindings: any[]) {
94
+ export function bindingTypeCoerce(bindings: any[]) {
95
95
  for (let i = 0; i < bindings.length; i++) {
96
96
  const binding = bindings[i]
97
97
  if (typeof binding !== "string") {
@@ -109,7 +109,12 @@ function bindingTypeCoerce(bindings: any[]) {
109
109
  dayjs(binding).isValid() &&
110
110
  !binding.includes(",")
111
111
  ) {
112
- bindings[i] = dayjs(binding).toDate()
112
+ let value: any
113
+ value = new Date(binding)
114
+ if (isNaN(value)) {
115
+ value = binding
116
+ }
117
+ bindings[i] = value
113
118
  }
114
119
  }
115
120
  return bindings
@@ -1,4 +1,4 @@
1
- import { default as MySQLIntegration } from "../mysql"
1
+ import { default as MySQLIntegration, bindingTypeCoerce } from "../mysql"
2
2
  jest.mock("mysql2")
3
3
 
4
4
  class TestConfiguration {
@@ -131,3 +131,21 @@ describe("MySQL Integration", () => {
131
131
  })
132
132
  })
133
133
  })
134
+
135
+ describe("bindingTypeCoercion", () => {
136
+ it("shouldn't coerce something that looks like a date", () => {
137
+ const response = bindingTypeCoerce(["202205-1500"])
138
+ expect(response[0]).toBe("202205-1500")
139
+ })
140
+
141
+ it("should coerce an actual date", () => {
142
+ const date = new Date("2023-06-13T14:24:22.620Z")
143
+ const response = bindingTypeCoerce(["2023-06-13T14:24:22.620Z"])
144
+ expect(response[0]).toEqual(date)
145
+ })
146
+
147
+ it("should coerce numbers", () => {
148
+ const response = bindingTypeCoerce(["0"])
149
+ expect(response[0]).toEqual(0)
150
+ })
151
+ })
@@ -328,3 +328,27 @@ export function finaliseExternalTables(
328
328
  .reduce((r, [k, v]) => ({ ...r, [k]: v }), {})
329
329
  return { tables: finalTables, errors }
330
330
  }
331
+
332
+ /**
333
+ * Checks if the provided input is an object, but specifically not a date type object.
334
+ * Used during coercion of types and relationship handling, dates are considered valid
335
+ * and can be used as a display field, but objects and arrays cannot.
336
+ * @param testValue an unknown type which this function will attempt to extract
337
+ * a valid primary display string from.
338
+ */
339
+ export function getPrimaryDisplay(testValue: unknown): string | undefined {
340
+ if (testValue instanceof Date) {
341
+ return testValue.toISOString()
342
+ }
343
+ if (
344
+ Array.isArray(testValue) &&
345
+ testValue[0] &&
346
+ typeof testValue[0] !== "object"
347
+ ) {
348
+ return testValue.join(", ")
349
+ }
350
+ if (typeof testValue === "object") {
351
+ return undefined
352
+ }
353
+ return testValue as string
354
+ }