@ronin/compiler 0.14.6-leo-ron-1099-1-experimental-337 → 0.14.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.
Files changed (2) hide show
  1. package/dist/index.js +9 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -557,10 +557,10 @@ var handleTo = (models, model, statementParams, queryType, dependencyStatements,
557
557
  delete toInstruction[fieldSlug];
558
558
  const associativeModelSlug = composeAssociationModelSlug(model, fieldDetails.field);
559
559
  const composeStatement = (subQueryType, value) => {
560
- const source = queryType === "add" ? toInstruction : withInstruction;
560
+ const source = queryType === "add" ? { id: toInstruction.id } : withInstruction;
561
561
  const recordDetails = { source };
562
562
  if (value) recordDetails.target = value;
563
- const query = compileQueryInput(
563
+ return compileQueryInput(
564
564
  {
565
565
  [subQueryType]: {
566
566
  [associativeModelSlug]: subQueryType === "add" ? { to: recordDetails } : { with: recordDetails }
@@ -570,20 +570,19 @@ var handleTo = (models, model, statementParams, queryType, dependencyStatements,
570
570
  [],
571
571
  { returning: false }
572
572
  ).main;
573
- dependencyStatements.push({ ...query, after: true });
574
573
  };
575
574
  if (Array.isArray(fieldValue)) {
576
- if (queryType === "set") composeStatement("remove");
575
+ dependencyStatements.push(composeStatement("remove"));
577
576
  for (const record of fieldValue) {
578
- composeStatement("add", record);
577
+ dependencyStatements.push(composeStatement("add", record));
579
578
  }
580
579
  } else if (isObject(fieldValue)) {
581
580
  const value = fieldValue;
582
581
  for (const recordToAdd of value.containing || []) {
583
- composeStatement("add", recordToAdd);
582
+ dependencyStatements.push(composeStatement("add", recordToAdd));
584
583
  }
585
584
  for (const recordToRemove of value.notContaining || []) {
586
- composeStatement("remove", recordToRemove);
585
+ dependencyStatements.push(composeStatement("remove", recordToRemove));
587
586
  }
588
587
  }
589
588
  }
@@ -1985,21 +1984,19 @@ var Transaction = class {
1985
1984
  });
1986
1985
  const statements = [];
1987
1986
  for (const query of queries) {
1988
- const { dependencies, main, selectedFields } = compileQueryInput(
1987
+ const result = compileQueryInput(
1989
1988
  query,
1990
1989
  modelsWithPresets,
1991
1990
  options?.inlineParams ? null : [],
1992
1991
  { expandColumns: options?.expandColumns }
1993
1992
  );
1994
- const preDependencies = dependencies.filter(({ after }) => !after);
1995
- const postDependencies = dependencies.map(({ after, ...rest }) => after ? rest : null).filter((item) => item != null);
1996
- const subStatements = [...preDependencies, main, ...postDependencies];
1993
+ const subStatements = [...result.dependencies, result.main];
1997
1994
  this.statements.push(...subStatements);
1998
1995
  this.#internalStatements.push(
1999
1996
  ...subStatements.map((statement) => ({
2000
1997
  ...statement,
2001
1998
  query,
2002
- selectedFields
1999
+ selectedFields: result.selectedFields
2003
2000
  }))
2004
2001
  );
2005
2002
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.14.6-leo-ron-1099-1-experimental-337",
3
+ "version": "0.14.6",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {