@strapi/database 4.4.5 → 4.4.6
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/lib/metadata/index.js
CHANGED
|
@@ -9,6 +9,21 @@ class Metadata extends Map {
|
|
|
9
9
|
add(meta) {
|
|
10
10
|
return this.set(meta.uid, meta);
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validate the DB metadata, throwing an error if a duplicate DB table name is detected
|
|
15
|
+
*/
|
|
16
|
+
validate() {
|
|
17
|
+
const seenTables = new Map();
|
|
18
|
+
for (const meta of this.values()) {
|
|
19
|
+
if (seenTables.get(meta.tableName)) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`DB table "${meta.tableName}" already exists. Change the collectionName of the related content type.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
seenTables.set(meta.tableName, true);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
// TODO: check if there isn't an attribute with an id already
|
|
@@ -81,6 +96,7 @@ const createMetadata = (models = []) => {
|
|
|
81
96
|
meta.columnToAttribute = columnToAttribute;
|
|
82
97
|
}
|
|
83
98
|
|
|
99
|
+
metadata.validate();
|
|
84
100
|
return metadata;
|
|
85
101
|
};
|
|
86
102
|
|
|
@@ -83,7 +83,13 @@ const processPopulate = (populate, ctx) => {
|
|
|
83
83
|
continue;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
//
|
|
86
|
+
// Make sure to query the join column value if needed,
|
|
87
|
+
// so that we can apply the populate later on
|
|
88
|
+
if (attribute.joinColumn) {
|
|
89
|
+
qb.addSelect(attribute.joinColumn.name);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Make sure id is present for future populate queries
|
|
87
93
|
if (_.has('id', meta.attributes)) {
|
|
88
94
|
qb.addSelect('id');
|
|
89
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/database",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.6",
|
|
4
4
|
"description": "Strapi's database layer",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"node": ">=14.19.1 <=18.x.x",
|
|
43
43
|
"npm": ">=6.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "788ea22ba6fc367f4d260e21e04e345bda0a12d9"
|
|
46
46
|
}
|