@ronin/compiler 0.11.7-leo-ron-1071-experimental-248 → 0.11.7

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -6064,7 +6064,8 @@ interface TransactionOptions {
6064
6064
  declare class Transaction {
6065
6065
  statements: Array<Statement>;
6066
6066
  models: Array<Model>;
6067
- private internalStatements;
6067
+ private queries;
6068
+ private fields;
6068
6069
  constructor(queries: Array<Query>, options?: TransactionOptions);
6069
6070
  /**
6070
6071
  * Composes SQL statements for the provided RONIN queries.
package/dist/index.js CHANGED
@@ -1570,12 +1570,14 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
1570
1570
 
1571
1571
  // src/index.ts
1572
1572
  var Transaction = class {
1573
- statements = [];
1573
+ statements;
1574
1574
  models = [];
1575
- internalStatements = [];
1575
+ queries;
1576
+ fields = [];
1576
1577
  constructor(queries, options) {
1577
1578
  const models = options?.models || [];
1578
- this.compileQueries(queries, models, options);
1579
+ this.statements = this.compileQueries(queries, models, options);
1580
+ this.queries = queries;
1579
1581
  }
1580
1582
  /**
1581
1583
  * Composes SQL statements for the provided RONIN queries.
@@ -1605,15 +1607,8 @@ var Transaction = class {
1605
1607
  options?.inlineParams ? null : [],
1606
1608
  { expandColumns: options?.expandColumns }
1607
1609
  );
1608
- const subStatements = [...result.dependencies, result.main];
1609
- this.statements.push(...subStatements);
1610
- this.internalStatements.push(
1611
- ...subStatements.map((statement) => ({
1612
- ...statement,
1613
- query,
1614
- fields: result.loadedFields
1615
- }))
1616
- );
1610
+ statements.push(...result.dependencies, result.main);
1611
+ this.fields.push(result.loadedFields);
1617
1612
  }
1618
1613
  this.models = modelListWithPresets;
1619
1614
  return statements;
@@ -1660,16 +1655,19 @@ var Transaction = class {
1660
1655
  * RONIN record, an array of RONIN records, or a RONIN count result.
1661
1656
  */
1662
1657
  formatResults(results, raw = true) {
1663
- const normalizedResults = raw ? results : results.map((rows) => {
1658
+ const relevantResults = results.filter((_, index) => {
1659
+ return this.statements[index].returning;
1660
+ });
1661
+ const normalizedResults = raw ? relevantResults : relevantResults.map((rows) => {
1664
1662
  return rows.map((row) => {
1665
1663
  if (Array.isArray(row)) return row;
1666
1664
  if (row["COUNT(*)"]) return [row["COUNT(*)"]];
1667
1665
  return Object.values(row);
1668
1666
  });
1669
1667
  });
1670
- const formattedResults = normalizedResults.map((rows, index) => {
1671
- const { returning, query, fields: rawModelFields } = this.internalStatements[index];
1672
- if (!returning) return null;
1668
+ return normalizedResults.map((rows, index) => {
1669
+ const query = this.queries.at(-index);
1670
+ const rawModelFields = this.fields.at(-index);
1673
1671
  const { queryType, queryModel, queryInstructions } = splitQuery(query);
1674
1672
  const model = getModelBySlug(this.models, queryModel);
1675
1673
  const modelFields = Object.fromEntries(
@@ -1721,7 +1719,6 @@ var Transaction = class {
1721
1719
  }
1722
1720
  return output;
1723
1721
  });
1724
- return formattedResults.filter((result) => result !== null);
1725
1722
  }
1726
1723
  };
1727
1724
  var CLEAN_ROOT_MODEL = omit(ROOT_MODEL, ["system"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.11.7-leo-ron-1071-experimental-248",
3
+ "version": "0.11.7",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {