@ronin/compiler 0.17.21-leo-pagination-bug-experimental-424 → 0.17.21-leo-pagination-bug-experimental-426

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 +18 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -396,7 +396,7 @@ var handleOrderedBy = (model, instruction) => {
396
396
  };
397
397
 
398
398
  // src/instructions/selecting.ts
399
- var handleSelecting = (models, model, statementParams, single, instructions, queryType, options = { inlineDefaults: false }) => {
399
+ var handleSelecting = (models, model, statementParams, queryType, single, instructions, options = { inlineDefaults: false }) => {
400
400
  let isJoining = false;
401
401
  const selectedFields = filterSelectedFields(
402
402
  model,
@@ -444,13 +444,14 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
444
444
  models,
445
445
  { ...subQueryModel, tableAlias: `including_${subMountingPath}` },
446
446
  statementParams,
447
+ queryType2,
447
448
  subSingle,
448
449
  {
449
450
  selecting: queryInstructions?.selecting,
450
451
  including: queryInstructions?.including,
451
- limitedTo: instructions.limitedTo
452
+ orderedBy: queryInstructions?.orderedBy,
453
+ limitedTo: queryInstructions?.limitedTo
452
454
  },
453
- queryType2,
454
455
  { ...options, mountingPath: subMountingPath }
455
456
  );
456
457
  if (nestedColumns !== "*") joinedColumns.push(nestedColumns);
@@ -473,13 +474,19 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
473
474
  });
474
475
  }
475
476
  }
476
- if (queryType === "get" && !single && !selectedFields.some((field) => field.slug === "ronin.createdAt") && instructions.limitedTo) {
477
- selectedFields.push({
478
- ...getSystemFields(model.idPrefix)["ronin.createdAt"],
479
- slug: "ronin.createdAt",
480
- excluded: true,
481
- mountingPath: "ronin.createdAt"
477
+ if (queryType === "get" && !single && typeof instructions.limitedTo !== "undefined") {
478
+ const orderedFields = Object.values(instructions.orderedBy || {}).flat().map((fieldSlug) => {
479
+ return getFieldFromModel(model, fieldSlug, { instructionName: "orderedBy" });
482
480
  });
481
+ for (const orderedField of orderedFields) {
482
+ const { field } = orderedField;
483
+ if (selectedFields.some(({ slug }) => slug === field.slug)) continue;
484
+ selectedFields.push({
485
+ slug: field.slug,
486
+ mountingPath: field.slug,
487
+ excluded: true
488
+ });
489
+ }
483
490
  }
484
491
  const columns = selectedFields.map((selectedField) => {
485
492
  if (selectedField.mountedValue) {
@@ -1120,13 +1127,14 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
1120
1127
  models,
1121
1128
  model,
1122
1129
  statementParams,
1130
+ queryType,
1123
1131
  single,
1124
1132
  {
1125
1133
  selecting: instructions?.selecting,
1126
1134
  including: instructions?.including,
1135
+ orderedBy: instructions?.orderedBy,
1127
1136
  limitedTo: instructions?.limitedTo
1128
1137
  },
1129
- queryType,
1130
1138
  // biome-ignore lint/complexity/useSimplifiedLogicExpression: This is needed.
1131
1139
  { inlineDefaults: options?.inlineDefaults || false }
1132
1140
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.17.21-leo-pagination-bug-experimental-424",
3
+ "version": "0.17.21-leo-pagination-bug-experimental-426",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {