strapi-plugin-i-relate-to-this 0.2.1 → 0.3.1

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.
@@ -84,7 +84,7 @@ const List = ({
84
84
  ] }, contentTypeTitle));
85
85
  };
86
86
  const Panel = (props) => ({
87
- title: "Relations to this entry",
87
+ title: "One way Relations to this entry",
88
88
  content: /* @__PURE__ */ jsxRuntime.jsx(List, { ...props })
89
89
  });
90
90
  const index = {
@@ -83,7 +83,7 @@ const List = ({
83
83
  ] }, contentTypeTitle));
84
84
  };
85
85
  const Panel = (props) => ({
86
- title: "Relations to this entry",
86
+ title: "One way Relations to this entry",
87
87
  content: /* @__PURE__ */ jsx(List, { ...props })
88
88
  });
89
89
  const index = {
@@ -96,9 +96,12 @@ const search = async (id, status, parent) => {
96
96
  const relationIdColumn = type === "relation" ? strapi.db.metadata.identifiers.getJoinColumnAttributeIdName(
97
97
  snakeCase__default.default(modelName)
98
98
  ) : "entity_id";
99
- const parentIdColumn = type === "relation" ? strapi.db.metadata.identifiers.getJoinColumnAttributeIdName(
99
+ let parentIdColumn = type === "relation" ? strapi.db.metadata.identifiers.getJoinColumnAttributeIdName(
100
100
  snakeCase__default.default(parent.modelName)
101
101
  ) : "cmp_id";
102
+ if (parentIdColumn === relationIdColumn) {
103
+ parentIdColumn = `inv_${parentIdColumn}`;
104
+ }
102
105
  const tableName = type === "relation" ? `${snakeCase__default.default(`${collectionName} ${key} lnk`)}` : `${collectionName}_cmps`;
103
106
  const relationsInTable = await strapi.db.getConnection(tableName).where({
104
107
  [parentIdColumn]: id,
@@ -92,9 +92,12 @@ const search = async (id, status, parent) => {
92
92
  const relationIdColumn = type === "relation" ? strapi.db.metadata.identifiers.getJoinColumnAttributeIdName(
93
93
  snakeCase(modelName)
94
94
  ) : "entity_id";
95
- const parentIdColumn = type === "relation" ? strapi.db.metadata.identifiers.getJoinColumnAttributeIdName(
95
+ let parentIdColumn = type === "relation" ? strapi.db.metadata.identifiers.getJoinColumnAttributeIdName(
96
96
  snakeCase(parent.modelName)
97
97
  ) : "cmp_id";
98
+ if (parentIdColumn === relationIdColumn) {
99
+ parentIdColumn = `inv_${parentIdColumn}`;
100
+ }
98
101
  const tableName = type === "relation" ? `${snakeCase(`${collectionName} ${key} lnk`)}` : `${collectionName}_cmps`;
99
102
  const relationsInTable = await strapi.db.getConnection(tableName).where({
100
103
  [parentIdColumn]: id,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.1",
2
+ "version": "0.3.1",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {