@strapi/database 4.25.14 → 4.25.16

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/dist/index.mjs CHANGED
@@ -3248,7 +3248,7 @@ const morphToMany = async (input, ctx) => {
3248
3248
  const { on, ...typePopulate } = populateValue;
3249
3249
  for (const type of Object.keys(idsByType)) {
3250
3250
  const ids = idsByType[type];
3251
- if (!db.metadata.get(type)) {
3251
+ if (!db.metadata.has(type)) {
3252
3252
  map2[type] = {};
3253
3253
  continue;
3254
3254
  }
@@ -3261,6 +3261,9 @@ const morphToMany = async (input, ctx) => {
3261
3261
  const matchingRows = joinResults.flatMap((joinResult) => {
3262
3262
  const id = joinResult[idColumn.name];
3263
3263
  const type = joinResult[typeColumn.name];
3264
+ if (!map2[type][id]) {
3265
+ return [];
3266
+ }
3264
3267
  const targetMeta = db.metadata.get(type);
3265
3268
  const fromTargetRow = (rowOrRows) => fromRow(targetMeta, rowOrRows);
3266
3269
  return (map2[type][id] || []).map((row) => {
@@ -3294,7 +3297,7 @@ const morphToOne = async (input, ctx) => {
3294
3297
  const { on, ...typePopulate } = populateValue;
3295
3298
  for (const type of Object.keys(idsByType)) {
3296
3299
  const ids = idsByType[type];
3297
- if (!db.metadata.get(type)) {
3300
+ if (!db.metadata.has(type)) {
3298
3301
  map2[type] = {};
3299
3302
  return;
3300
3303
  }
@@ -3305,7 +3308,7 @@ const morphToOne = async (input, ctx) => {
3305
3308
  results.forEach((result) => {
3306
3309
  const id = result[idColumn.name];
3307
3310
  const type = result[typeColumn.name];
3308
- if (!type || !id) {
3311
+ if (!type || !id || !map2[type][id]) {
3309
3312
  result[attributeName] = null;
3310
3313
  return;
3311
3314
  }