@ronin/compiler 0.10.3-leo-ron-1083-experimental-215 → 0.10.3-leo-ron-1083-experimental-216

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/index.js +20 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1190,7 +1190,8 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1190
1190
  return getFieldFromModel(model, slug, "selecting").fieldSelector;
1191
1191
  }).join(", ") : "*";
1192
1192
  if (instructions.including) {
1193
- const filteredObject = Object.entries(instructions.including).flatMap(([key, value]) => {
1193
+ const flatObject = flatten(instructions.including);
1194
+ const filteredObject = Object.entries(flatObject).flatMap(([key, value]) => {
1194
1195
  const symbol = getSymbol(value);
1195
1196
  if (symbol?.type === "query") {
1196
1197
  isJoining = true;
@@ -1202,27 +1203,28 @@ var handleSelecting = (models, model, statementParams, instructions, options) =>
1202
1203
  if (field.type === "group") return null;
1203
1204
  return model.fields.some((modelField) => modelField.slug === field.slug);
1204
1205
  }).filter((item) => item !== null);
1205
- return duplicatedFields.map((field) => ({
1206
- key: `${tableName}.${field.slug}`,
1207
- value: {
1208
- [RONIN_MODEL_SYMBOLS.EXPRESSION]: `${RONIN_MODEL_SYMBOLS.FIELD}${field.slug}`
1209
- }
1210
- }));
1206
+ return duplicatedFields.map((field) => {
1207
+ const value2 = parseFieldExpression(
1208
+ { ...queryModel, tableAlias: tableName },
1209
+ "including",
1210
+ `${RONIN_MODEL_SYMBOLS.FIELD}${field.slug}`
1211
+ );
1212
+ return {
1213
+ key: `${tableName}.${field.slug}`,
1214
+ value: value2
1215
+ };
1216
+ });
1217
+ }
1218
+ if (symbol?.type === "expression") {
1219
+ value = `(${parseFieldExpression(model, "including", symbol.value)})`;
1220
+ } else {
1221
+ value = prepareStatementValue(statementParams, value);
1211
1222
  }
1212
1223
  return { key, value };
1213
1224
  }).filter((entry) => entry !== null).map((entry) => [entry.key, entry.value]);
1214
- const newObjectEntries = Object.entries(flatten(Object.fromEntries(filteredObject)));
1215
- if (newObjectEntries.length > 0) {
1225
+ if (filteredObject.length > 0) {
1216
1226
  statement += ", ";
1217
- statement += newObjectEntries.map(([key, value]) => {
1218
- const symbol = getSymbol(value);
1219
- if (symbol?.type === "expression") {
1220
- value = `(${parseFieldExpression(model, "including", symbol.value)})`;
1221
- } else {
1222
- value = prepareStatementValue(statementParams, value);
1223
- }
1224
- return `${value} as "${key}"`;
1225
- }).join(", ");
1227
+ statement += filteredObject.map(([key, value]) => `${value} as "${key}"`).join(", ");
1226
1228
  }
1227
1229
  }
1228
1230
  return { columns: statement, isJoining };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.10.3-leo-ron-1083-experimental-215",
3
+ "version": "0.10.3-leo-ron-1083-experimental-216",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {