@ronin/compiler 0.17.19-corny-pagination-bug-experimental-416 → 0.17.19-leo-ron-1119-experimental-417

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.
package/dist/index.d.ts CHANGED
@@ -258,8 +258,6 @@ type InternalModelField = ModelField & {
258
258
  mountingPath: string;
259
259
  /** A custom value that was provided in the query, which is not stored in the DB. */
260
260
  mountedValue?: unknown;
261
- /** Indicator if the field should be excluded from the final records. */
262
- excluded?: boolean;
263
261
  };
264
262
  type ModelIndexField<T extends ModelEntityList<ModelField> = ModelEntityList<ModelField>> = {
265
263
  /** The collating sequence used for text placed inside the field. */
package/dist/index.js CHANGED
@@ -379,7 +379,7 @@ var handleOrderedBy = (model, instruction) => {
379
379
  };
380
380
 
381
381
  // src/instructions/selecting.ts
382
- var handleSelecting = (models, model, statementParams, single, instructions, queryType, options = { inlineDefaults: false }) => {
382
+ var handleSelecting = (models, model, statementParams, single, instructions, options = { inlineDefaults: false }) => {
383
383
  let isJoining = false;
384
384
  const selectedFields = filterSelectedFields(
385
385
  model,
@@ -403,9 +403,9 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
403
403
  for (const [key, value] of Object.entries(flatObject)) {
404
404
  const symbol2 = getQuerySymbol(value);
405
405
  if (symbol2?.type === "query") {
406
- const { queryType: queryType2, queryModel, queryInstructions } = splitQuery(symbol2.value);
406
+ const { queryType, queryModel, queryInstructions } = splitQuery(symbol2.value);
407
407
  const subQueryModel = getModelBySlug(models, queryModel);
408
- if (queryType2 === "count") {
408
+ if (queryType === "count") {
409
409
  const subSelect = compileQueryInput(symbol2.value, models, statementParams, {
410
410
  parentModel: { ...model, tableAlias: model.table },
411
411
  inlineDefaults: options.inlineDefaults
@@ -430,10 +430,8 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
430
430
  subSingle,
431
431
  {
432
432
  selecting: queryInstructions?.selecting,
433
- including: queryInstructions?.including,
434
- limitedTo: instructions.limitedTo
433
+ including: queryInstructions?.including
435
434
  },
436
- queryType2,
437
435
  { ...options, mountingPath: subMountingPath }
438
436
  );
439
437
  if (nestedColumns !== "*") joinedColumns.push(nestedColumns);
@@ -456,14 +454,6 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
456
454
  });
457
455
  }
458
456
  }
459
- if (queryType === "get" && !single && !selectedFields.some((field) => field.slug === "ronin.createdAt") && instructions.limitedTo) {
460
- selectedFields.push({
461
- ...getSystemFields(model.idPrefix)["ronin.createdAt"],
462
- slug: "ronin.createdAt",
463
- excluded: true,
464
- mountingPath: "ronin.createdAt"
465
- });
466
- }
467
457
  const columns = selectedFields.map((selectedField) => {
468
458
  if (selectedField.mountedValue) {
469
459
  return `${selectedField.mountedValue} as "${selectedField.slug}"`;
@@ -1087,18 +1077,6 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
1087
1077
  }
1088
1078
  });
1089
1079
  }
1090
- if (!single && (queryType === "get" && instructions?.limitedTo || queryType === "count" && (instructions?.before || instructions?.after))) {
1091
- instructions = instructions || {};
1092
- instructions.orderedBy = instructions.orderedBy || {};
1093
- instructions.orderedBy.ascending = instructions.orderedBy.ascending || [];
1094
- instructions.orderedBy.descending = instructions.orderedBy.descending || [];
1095
- if (![
1096
- ...instructions.orderedBy.ascending,
1097
- ...instructions.orderedBy.descending
1098
- ].includes("ronin.createdAt")) {
1099
- instructions.orderedBy.descending.push("ronin.createdAt");
1100
- }
1101
- }
1102
1080
  const { columns, isJoining, selectedFields } = handleSelecting(
1103
1081
  models,
1104
1082
  model,
@@ -1106,10 +1084,8 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
1106
1084
  single,
1107
1085
  {
1108
1086
  selecting: instructions?.selecting,
1109
- including: instructions?.including,
1110
- limitedTo: instructions?.limitedTo
1087
+ including: instructions?.including
1111
1088
  },
1112
- queryType,
1113
1089
  // biome-ignore lint/complexity/useSimplifiedLogicExpression: This is needed.
1114
1090
  { inlineDefaults: options?.inlineDefaults || false }
1115
1091
  );
@@ -1180,6 +1156,18 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
1180
1156
  );
1181
1157
  if (withStatement.length > 0) conditions.push(withStatement);
1182
1158
  }
1159
+ if (!single && (queryType === "get" && instructions?.limitedTo || queryType === "count" && (instructions?.before || instructions?.after))) {
1160
+ instructions = instructions || {};
1161
+ instructions.orderedBy = instructions.orderedBy || {};
1162
+ instructions.orderedBy.ascending = instructions.orderedBy.ascending || [];
1163
+ instructions.orderedBy.descending = instructions.orderedBy.descending || [];
1164
+ if (![
1165
+ ...instructions.orderedBy.ascending,
1166
+ ...instructions.orderedBy.descending
1167
+ ].includes("ronin.createdAt")) {
1168
+ instructions.orderedBy.descending.push("ronin.createdAt");
1169
+ }
1170
+ }
1183
1171
  if (instructions && (typeof instructions.before !== "undefined" || typeof instructions.after !== "undefined")) {
1184
1172
  if (single) {
1185
1173
  throw new RoninError({
@@ -2054,7 +2042,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
2054
2042
  const value = prepareStatementValue(statementParams, entityValue);
2055
2043
  json = `json_insert(${field}, '$.${slug2}', json(${value}))`;
2056
2044
  if (!existingModel[pluralType]) existingModel[pluralType] = {};
2057
- existingModel[pluralType][slug2] = jsonValue;
2045
+ existingModel[pluralType][slug2] = entityValue;
2058
2046
  break;
2059
2047
  }
2060
2048
  case "alter": {
@@ -2320,38 +2308,6 @@ var Transaction = class {
2320
2308
  );
2321
2309
  }
2322
2310
  }
2323
- const fieldsToDrop = selectedFields.filter((field) => field.excluded === true);
2324
- const deleteNestedProperty = (obj, path) => {
2325
- const parts = path.split(".");
2326
- const lastPart = parts.pop();
2327
- let current = obj;
2328
- for (const part of parts) {
2329
- if (!current || typeof current !== "object") return;
2330
- const currentAsRecord = current;
2331
- if (!(part in currentAsRecord)) return;
2332
- current = currentAsRecord[part];
2333
- }
2334
- if (typeof current === "object" && current !== null) {
2335
- delete current[lastPart];
2336
- }
2337
- if (parts.length > 0 && typeof current === "object" && current !== null && Object.keys(current).length === 0) {
2338
- let temp = obj;
2339
- for (let i = 0; i < parts.length - 1; i++) {
2340
- temp = temp[parts[i]];
2341
- }
2342
- const lastPart2 = parts.at(-1);
2343
- if (lastPart2) {
2344
- delete temp[lastPart2];
2345
- }
2346
- }
2347
- };
2348
- if (fieldsToDrop.length > 0) {
2349
- for (const record of result.records) {
2350
- for (const field of fieldsToDrop) {
2351
- deleteNestedProperty(record, field.slug);
2352
- }
2353
- }
2354
- }
2355
2311
  return result;
2356
2312
  }
2357
2313
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.17.19-corny-pagination-bug-experimental-416",
3
+ "version": "0.17.19-leo-ron-1119-experimental-417",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {