@ronin/compiler 0.11.4-leo-ron-1083-2-experimental-239 → 0.11.4-leo-ron-1083-experimental-241

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 +13 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -658,7 +658,7 @@ var getFieldStatement = (models, model, field) => {
658
658
  if (field.type === "link") {
659
659
  if (field.kind === "many") return null;
660
660
  const actions = field.actions || {};
661
- const targetTable = getModelBySlug(models, field.target).table;
661
+ const targetTable = getModelBySlug([...models, model], field.target).table;
662
662
  statement += ` REFERENCES ${targetTable}("id")`;
663
663
  for (const trigger in actions) {
664
664
  const triggerName = trigger.toUpperCase().slice(2);
@@ -1229,7 +1229,12 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1229
1229
  }
1230
1230
  const queryModelFields = queryInstructions?.selecting ? subQueryModel.fields.filter((field) => {
1231
1231
  return queryInstructions.selecting?.includes(field.slug);
1232
- }) : 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
+ );
1233
1238
  for (const field of queryModelFields) {
1234
1239
  loadedFields.push({ ...field, parentField: key });
1235
1240
  if (expandColumns) {
@@ -1273,7 +1278,12 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1273
1278
  }).join(", ");
1274
1279
  loadedFields = [...selectedFields, ...loadedFields];
1275
1280
  } else {
1276
- loadedFields = [...model.fields, ...loadedFields];
1281
+ loadedFields = [
1282
+ ...model.fields.filter(
1283
+ (field) => !(field.type === "link" && field.kind === "many")
1284
+ ),
1285
+ ...loadedFields
1286
+ ];
1277
1287
  }
1278
1288
  if (instructions.including && Object.keys(instructions.including).length > 0) {
1279
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-239",
3
+ "version": "0.11.4-leo-ron-1083-experimental-241",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {