@ronin/compiler 0.7.0 → 0.7.1

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 +14 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1127,16 +1127,25 @@ var handleSelecting = (model, statementParams, instructions) => {
1127
1127
  return getFieldFromModel(model, slug, "selecting").fieldSelector;
1128
1128
  }).join(", ") : "*";
1129
1129
  if (instructions.including) {
1130
- const filteredObject = Object.entries(instructions.including).filter(([_, value]) => {
1130
+ const filteredObject = Object.entries(instructions.including).map(([key, value]) => {
1131
1131
  const symbol = getSymbol(value);
1132
- const hasQuery = symbol?.type === "query";
1133
- if (hasQuery) isJoining = true;
1134
- return !hasQuery;
1135
- });
1132
+ if (symbol) {
1133
+ if (symbol.type === "query") {
1134
+ isJoining = true;
1135
+ return null;
1136
+ }
1137
+ if (symbol.type === "expression") {
1138
+ value = parseFieldExpression(model, "including", symbol.value);
1139
+ }
1140
+ }
1141
+ return [key, value];
1142
+ }).filter((entry) => entry !== null);
1136
1143
  const newObjectEntries = Object.entries(flatten(Object.fromEntries(filteredObject)));
1137
1144
  if (newObjectEntries.length > 0) {
1138
1145
  statement += ", ";
1139
1146
  statement += newObjectEntries.map(([key, value]) => {
1147
+ if (typeof value === "string" && value.startsWith('"'))
1148
+ return `(${value}) as "${key}"`;
1140
1149
  return `${prepareStatementValue(statementParams, value)} as "${key}"`;
1141
1150
  }).join(", ");
1142
1151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {