@ronin/compiler 0.11.5 → 0.11.6-leo-ron-1071-experimental-246

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -5998,11 +5998,13 @@ type NativeRecord = Record<string, unknown> & {
5998
5998
  };
5999
5999
  type SingleRecordResult<T = NativeRecord> = {
6000
6000
  record: T | null;
6001
+ modelFields: Record<ModelField['slug'], ModelField['type']>;
6001
6002
  };
6002
6003
  type MultipleRecordResult = {
6003
6004
  records: Array<NativeRecord>;
6004
6005
  moreAfter?: string;
6005
6006
  moreBefore?: string;
6007
+ modelFields: Record<ModelField['slug'], ModelField['type']>;
6006
6008
  };
6007
6009
  type AmountResult = {
6008
6010
  amount: number;
package/dist/index.js CHANGED
@@ -1599,8 +1599,7 @@ var Transaction = class {
1599
1599
  const modelListWithPresets = modelList.map((model) => {
1600
1600
  return addDefaultModelPresets(modelList, model);
1601
1601
  });
1602
- const dependencyStatements = [];
1603
- const mainStatements = [];
1602
+ const statements = [];
1604
1603
  for (const query of queries) {
1605
1604
  const result = compileQueryInput(
1606
1605
  query,
@@ -1608,12 +1607,11 @@ var Transaction = class {
1608
1607
  options?.inlineParams ? null : [],
1609
1608
  { expandColumns: options?.expandColumns }
1610
1609
  );
1611
- dependencyStatements.push(...result.dependencies);
1612
- mainStatements.push(result.main);
1610
+ statements.push(...result.dependencies, result.main);
1613
1611
  this.fields.push(result.loadedFields);
1614
1612
  }
1615
1613
  this.models = modelListWithPresets;
1616
- return [...dependencyStatements, ...mainStatements];
1614
+ return statements;
1617
1615
  };
1618
1616
  formatRows(fields, rows, single) {
1619
1617
  const records = [];
@@ -1669,19 +1667,26 @@ var Transaction = class {
1669
1667
  });
1670
1668
  return normalizedResults.map((rows, index) => {
1671
1669
  const query = this.queries.at(-index);
1672
- const fields = this.fields.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);
1673
+ const modelFields = Object.fromEntries(
1674
+ model.fields.map((field) => [field.slug, field.type])
1675
+ );
1675
1676
  if (queryType === "count") {
1676
1677
  return { amount: rows[0][0] };
1677
1678
  }
1678
1679
  const single = queryModel !== model.pluralSlug;
1679
1680
  if (single) {
1680
- return { record: rows[0] ? this.formatRows(fields, rows, single) : null };
1681
+ return {
1682
+ record: rows[0] ? this.formatRows(rawModelFields, rows, single) : null,
1683
+ modelFields
1684
+ };
1681
1685
  }
1682
1686
  const pageSize = queryInstructions?.limitedTo;
1683
1687
  const output = {
1684
- records: this.formatRows(fields, rows, single)
1688
+ records: this.formatRows(rawModelFields, rows, single),
1689
+ modelFields
1685
1690
  };
1686
1691
  if (pageSize && output.records.length > 0) {
1687
1692
  if (output.records.length > pageSize) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.11.5",
3
+ "version": "0.11.6-leo-ron-1071-experimental-246",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {