@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 +2 -1
- package/dist/index.js +14 -17
- package/package.json +1 -1
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
|
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
|
-
|
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
|
-
|
1609
|
-
this.
|
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
|
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
|
-
|
1671
|
-
const
|
1672
|
-
|
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"]);
|