@ronin/compiler 0.17.15 → 0.17.16-leo-ron-1117-experimental-407
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.
- package/dist/index.js +10 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -444,6 +444,8 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
|
|
444
444
|
} else {
|
445
445
|
mountedValue = prepareStatementValue(statementParams, value);
|
446
446
|
}
|
447
|
+
const existingField = selectedFields.findIndex((field) => field.slug === key);
|
448
|
+
if (existingField > -1) selectedFields.splice(existingField, 1);
|
447
449
|
selectedFields.push({
|
448
450
|
slug: key,
|
449
451
|
mountingPath: key,
|
@@ -1253,18 +1255,18 @@ var filterSelectedFields = (model, instruction) => {
|
|
1253
1255
|
return selectedFields;
|
1254
1256
|
};
|
1255
1257
|
var prepareStatementValue = (statementParams, value) => {
|
1258
|
+
const inlineParams = !statementParams;
|
1256
1259
|
if (value === null) return "NULL";
|
1257
|
-
if (!statementParams) {
|
1258
|
-
if (typeof value === "string") return `'${value}'`;
|
1259
|
-
const valueString = typeof value === "object" ? `json('${JSON.stringify(value, replaceJSON)}')` : value.toString();
|
1260
|
-
return valueString;
|
1261
|
-
}
|
1262
1260
|
let formattedValue = value;
|
1263
1261
|
if (Array.isArray(value) || isObject(value)) {
|
1264
|
-
formattedValue = JSON.stringify(value);
|
1262
|
+
formattedValue = JSON.stringify(value, inlineParams ? replaceJSON : void 0);
|
1265
1263
|
} else if (typeof value === "boolean") {
|
1266
1264
|
formattedValue = value ? 1 : 0;
|
1267
1265
|
}
|
1266
|
+
if (!statementParams) {
|
1267
|
+
if (typeof formattedValue === "string") return `'${formattedValue}'`;
|
1268
|
+
return formattedValue.toString();
|
1269
|
+
}
|
1268
1270
|
const index = statementParams.push(formattedValue);
|
1269
1271
|
return `?${index}`;
|
1270
1272
|
};
|
@@ -2038,7 +2040,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
|
|
2038
2040
|
case "create": {
|
2039
2041
|
const { slug: slug2, ...entityValue } = jsonValue;
|
2040
2042
|
const value = prepareStatementValue(statementParams, entityValue);
|
2041
|
-
json = `json_insert(${field}, '$.${slug2}', ${value})`;
|
2043
|
+
json = `json_insert(${field}, '$.${slug2}', json(${value}))`;
|
2042
2044
|
if (!existingModel[pluralType]) existingModel[pluralType] = {};
|
2043
2045
|
existingModel[pluralType][slug2] = jsonValue;
|
2044
2046
|
break;
|
@@ -2055,7 +2057,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
|
|
2055
2057
|
Object.assign(targetEntities[newSlug], entityValue);
|
2056
2058
|
delete targetEntities[slug];
|
2057
2059
|
const value = prepareStatementValue(statementParams, targetEntities[newSlug]);
|
2058
|
-
json = `json_insert(json_remove(${field}, '$.${slug}'), '$.${newSlug}', ${value})`;
|
2060
|
+
json = `json_insert(json_remove(${field}, '$.${slug}'), '$.${newSlug}', json(${value}))`;
|
2059
2061
|
} else {
|
2060
2062
|
Object.assign(targetEntities[slug], jsonValue);
|
2061
2063
|
const value = prepareStatementValue(statementParams, jsonValue);
|