@ronin/compiler 0.14.3-leo-ron-1099-1-experimental-322 → 0.14.3-leo-ron-1099-1-experimental-323

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 +17 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23,12 +23,14 @@ var RAW_FIELD_TYPES = ["string", "number", "boolean"];
23
23
  var CURRENT_TIME_EXPRESSION = {
24
24
  [QUERY_SYMBOLS.EXPRESSION]: `strftime('%Y-%m-%dT%H:%M:%f', 'now') || 'Z'`
25
25
  };
26
- var composeIncludedTableAlias = (fieldSlug) => {
27
- return `including_${fieldSlug}`;
28
- };
29
26
  var MOUNTING_PATH_SUFFIX = /(.*?)(\{(\d+)\})?$/;
30
- var composeMountingPath = (input) => {
31
- return input.replace(MOUNTING_PATH_SUFFIX, (_, p, __, n) => `${p}{${n ? +n + 1 : 1}}`);
27
+ var composeMountingPath = (single, key, mountingPath) => {
28
+ const subMountingPath = key === "ronin_root" ? mountingPath ? mountingPath.replace(
29
+ MOUNTING_PATH_SUFFIX,
30
+ (_, p, __, n) => `${p}{${n ? +n + 1 : 1}}`
31
+ ) : void 0 : `${mountingPath ? `${mountingPath}.` : ""}${single ? key : `${key}[0]`}`;
32
+ const tableAlias = `including_${subMountingPath || key}`;
33
+ return { subMountingPath, tableAlias };
32
34
  };
33
35
  var MODEL_ENTITY_ERROR_CODES = {
34
36
  field: "FIELD_NOT_FOUND",
@@ -316,8 +318,11 @@ var handleIncluding = (models, model, statementParams, single, instruction, opti
316
318
  let joinType = "LEFT";
317
319
  let relatedTableSelector = `"${relatedModel.table}"`;
318
320
  const subSingle = queryModel !== relatedModel.pluralSlug;
319
- const subMountingPath = ephemeralFieldSlug === "ronin_root" ? options.mountingPath ? composeMountingPath(options.mountingPath) : void 0 : `${options?.mountingPath ? `${options?.mountingPath}.` : ""}${subSingle ? ephemeralFieldSlug : `${ephemeralFieldSlug}[0]`}`;
320
- const tableAlias = composeIncludedTableAlias(subMountingPath || ephemeralFieldSlug);
321
+ const { tableAlias, subMountingPath } = composeMountingPath(
322
+ subSingle,
323
+ ephemeralFieldSlug,
324
+ options.mountingPath
325
+ );
321
326
  if (!modifiableQueryInstructions?.with) {
322
327
  joinType = "CROSS";
323
328
  if (subSingle) {
@@ -439,8 +444,11 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
439
444
  const subSingle = queryModel !== subQueryModel.pluralSlug;
440
445
  if (!model.tableAlias)
441
446
  model.tableAlias = single && !subSingle ? `sub_${model.table}` : model.table;
442
- const subMountingPath = key === "ronin_root" ? options.mountingPath ? composeMountingPath(options.mountingPath) : void 0 : `${options?.mountingPath ? `${options?.mountingPath}.` : ""}${subSingle ? key : `${key}[0]`}`;
443
- const tableAlias = composeIncludedTableAlias(subMountingPath || key);
447
+ const { tableAlias, subMountingPath } = composeMountingPath(
448
+ subSingle,
449
+ key,
450
+ options.mountingPath
451
+ );
444
452
  const { columns: nestedColumns, selectedFields: nestedSelectedFields } = handleSelecting(
445
453
  models,
446
454
  { ...subQueryModel, tableAlias },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.14.3-leo-ron-1099-1-experimental-322",
3
+ "version": "0.14.3-leo-ron-1099-1-experimental-323",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {