@ronin/compiler 0.14.3-leo-ron-1099-1-experimental-323 → 0.14.3-leo-ron-1099-1-experimental-325

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2007,7 +2007,7 @@ var Transaction = class {
2007
2007
  const records = [];
2008
2008
  for (const row of rows) {
2009
2009
  const record = fields.reduce((acc, field, fieldIndex) => {
2010
- const newSlug = field.mountingPath;
2010
+ let newSlug = field.mountingPath;
2011
2011
  let newValue = row[fieldIndex];
2012
2012
  if (field.type === "json") {
2013
2013
  newValue = JSON.parse(newValue);
@@ -2019,6 +2019,29 @@ var Transaction = class {
2019
2019
  return { slug, ...attributes };
2020
2020
  }) : [];
2021
2021
  }
2022
+ const { parentField, parentIsArray } = (() => {
2023
+ const lastDotIndex = newSlug.lastIndexOf(".");
2024
+ if (lastDotIndex === -1) return { parentField: null };
2025
+ const parent = newSlug.slice(0, lastDotIndex);
2026
+ if (parent.endsWith("[0]")) {
2027
+ return { parentField: parent.slice(0, -3), parentIsArray: true };
2028
+ }
2029
+ return { parentField: parent };
2030
+ })();
2031
+ if (parentField) {
2032
+ if (field.slug === "id" && newValue === null) {
2033
+ newSlug = parentField;
2034
+ newValue = parentIsArray ? [] : null;
2035
+ }
2036
+ const parentFields = newSlug.split(".").map((_, index, array) => array.slice(0, index + 1).join(".")).reverse();
2037
+ if (parentFields.some((item) => {
2038
+ const isArray = item.endsWith("[0]");
2039
+ const value = getProperty(acc, item.replaceAll("[0]", ""));
2040
+ return isArray ? Array.isArray(value) && value.length === 0 : value === null;
2041
+ })) {
2042
+ return acc;
2043
+ }
2044
+ }
2022
2045
  setProperty(acc, newSlug, newValue);
2023
2046
  return acc;
2024
2047
  }, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.14.3-leo-ron-1099-1-experimental-323",
3
+ "version": "0.14.3-leo-ron-1099-1-experimental-325",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {