@budibase/frontend-core 3.39.26 → 3.39.28

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "3.39.26",
3
+ "version": "3.39.28",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
@@ -23,5 +23,5 @@
23
23
  "devDependencies": {
24
24
  "vitest": "^4.1.0"
25
25
  },
26
- "gitHead": "6d7fa46d35e6d68da050e76f4c1662adaf25a182"
26
+ "gitHead": "1ad76cd4e4a5dc308900e2a7db331e20a013f65c"
27
27
  }
@@ -8,7 +8,9 @@ export function getTableFields(tables, linkField) {
8
8
  const linkFields = getFields(tables, Object.values(table.schema), {
9
9
  allowLinks: false,
10
10
  })
11
- return linkFields
11
+ // Expose the related row's _id so relationships can be filtered on the same
12
+ // value a relationship picker emits and a saved row stores.
13
+ return [{ name: "_id", type: "string" }, ...linkFields]
12
14
  .sort((a, b) => a.name.localeCompare(b.name))
13
15
  .map(field => ({
14
16
  ...field,
@@ -26,9 +26,15 @@ describe("search fields", () => {
26
26
  const tables = [baseTable, relatedTable]
27
27
 
28
28
  describe("getTableFields", () => {
29
- it("excludes nested link fields when allowLinks is false", () => {
29
+ it("exposes the related _id and excludes nested link fields", () => {
30
30
  const fields = getTableFields(tables, baseTable.schema.rel)
31
- expect(fields.map(field => field.name)).toEqual(["rel.title"])
31
+ expect(fields.map(field => field.name)).toEqual(["rel._id", "rel.title"])
32
+ })
33
+
34
+ it("exposes the related _id as a filterable string type", () => {
35
+ const fields = getTableFields(tables, baseTable.schema.rel)
36
+ const idField = fields.find(field => field.name === "rel._id")
37
+ expect(idField).toEqual({ name: "rel._id", type: "string" })
32
38
  })
33
39
 
34
40
  it("returns empty for non-sql related tables", () => {
@@ -58,9 +64,41 @@ describe("search fields", () => {
58
64
  })
59
65
  const names = fields.map(field => field.name)
60
66
  expect(names).toEqual(
61
- expect.arrayContaining(["name", "rel", "rel.title"])
67
+ expect.arrayContaining(["name", "rel", "rel._id", "rel.title"])
68
+ )
69
+ expect(names).not.toContain("rel.otherLink")
70
+ })
71
+
72
+ it("drills relationships by default when allowLinks is omitted", () => {
73
+ const names = getFields(tables, Object.values(baseTable.schema)).map(
74
+ field => field.name
75
+ )
76
+ expect(names).toEqual(
77
+ expect.arrayContaining(["name", "rel", "rel._id", "rel.title"])
78
+ )
79
+ })
80
+
81
+ it("adds a distinct _id for each relationship", () => {
82
+ const authors = table("t6", { fullName: field("fullName", "string") })
83
+ const categories = table("t7", { code: field("code", "string") })
84
+ const posts = table("t8", {
85
+ name: field("name", "string"),
86
+ author: field("author", "link", { tableId: "t6" }),
87
+ category: field("category", "link", { tableId: "t7" }),
88
+ })
89
+ const names = getFields(
90
+ [posts, authors, categories],
91
+ Object.values(posts.schema),
92
+ { allowLinks: true }
93
+ ).map(field => field.name)
94
+ expect(names).toEqual(
95
+ expect.arrayContaining([
96
+ "author._id",
97
+ "author.fullName",
98
+ "category._id",
99
+ "category.code",
100
+ ])
62
101
  )
63
- expect(names).not.toEqual(expect.arrayContaining(["rel.otherLink"]))
64
102
  })
65
103
 
66
104
  it("appends static formula fields even when allowLinks is false", () => {