@ronin/compiler 0.11.4-leo-ron-1083-2-experimental-238 → 0.11.4-leo-ron-1083-2-experimental-240

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 +16 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1209,6 +1209,7 @@ var handleOrderedBy = (model, instruction) => {
1209
1209
  // src/instructions/selecting.ts
1210
1210
  var handleSelecting = (models, model, statementParams, instructions, options) => {
1211
1211
  let loadedFields = [];
1212
+ let expandColumns = false;
1212
1213
  let statement = "*";
1213
1214
  let isJoining = false;
1214
1215
  if (instructions.including) {
@@ -1217,9 +1218,10 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1217
1218
  for (const [key, value] of Object.entries(flatObject)) {
1218
1219
  const symbol = getSymbol(value);
1219
1220
  if (symbol?.type === "query") {
1220
- isJoining = true;
1221
1221
  const { queryModel, queryInstructions } = splitQuery(symbol.value);
1222
1222
  const subQueryModel = getModelBySlug(models, queryModel);
1223
+ isJoining = true;
1224
+ expandColumns = Boolean(options?.expandColumns || queryInstructions?.selecting);
1223
1225
  const tableAlias = composeIncludedTableAlias(key);
1224
1226
  const single = queryModel !== subQueryModel.pluralSlug;
1225
1227
  if (!single) {
@@ -1227,10 +1229,15 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1227
1229
  }
1228
1230
  const queryModelFields = queryInstructions?.selecting ? subQueryModel.fields.filter((field) => {
1229
1231
  return queryInstructions.selecting?.includes(field.slug);
1230
- }) : subQueryModel.fields;
1232
+ }) : (
1233
+ // Exclude link fields with cardinality "many", since those don't exist as columns.
1234
+ subQueryModel.fields.filter((field) => {
1235
+ return !(field.type === "link" && field.kind === "many");
1236
+ })
1237
+ );
1231
1238
  for (const field of queryModelFields) {
1232
1239
  loadedFields.push({ ...field, parentField: key });
1233
- if (options?.expandColumns) {
1240
+ if (expandColumns) {
1234
1241
  const newValue2 = parseFieldExpression(
1235
1242
  { ...subQueryModel, tableAlias },
1236
1243
  "including",
@@ -1254,7 +1261,6 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1254
1261
  });
1255
1262
  }
1256
1263
  }
1257
- const expandColumns = isJoining && options?.expandColumns;
1258
1264
  if (expandColumns) {
1259
1265
  instructions.selecting = model.fields.filter((field) => !(field.type === "link" && field.kind === "many")).map((field) => field.slug);
1260
1266
  }
@@ -1272,7 +1278,12 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1272
1278
  }).join(", ");
1273
1279
  loadedFields = [...selectedFields, ...loadedFields];
1274
1280
  } else {
1275
- loadedFields = [...model.fields, ...loadedFields];
1281
+ loadedFields = [
1282
+ ...model.fields.filter(
1283
+ (field) => !(field.type === "link" && field.kind === "many")
1284
+ ),
1285
+ ...loadedFields
1286
+ ];
1276
1287
  }
1277
1288
  if (instructions.including && Object.keys(instructions.including).length > 0) {
1278
1289
  statement += ", ";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.11.4-leo-ron-1083-2-experimental-238",
3
+ "version": "0.11.4-leo-ron-1083-2-experimental-240",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {