@ronin/compiler 0.14.2-leo-ron-1099-1-experimental-319 → 0.14.2-leo-ron-1099-1-experimental-320
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 +30 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -403,12 +403,10 @@ var handleOrderedBy = (model, instruction) => {
|
|
403
403
|
// src/instructions/selecting.ts
|
404
404
|
var handleSelecting = (models, model, statementParams, single, instructions, options = {}) => {
|
405
405
|
let isJoining = false;
|
406
|
-
const selectedFields = (
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
return field;
|
411
|
-
}) : model.fields).filter((field) => !(field.type === "link" && field.kind === "many")).map((field) => {
|
406
|
+
const selectedFields = filterSelectedFields(
|
407
|
+
model,
|
408
|
+
instructions.selecting
|
409
|
+
).filter((field) => !(field.type === "link" && field.kind === "many")).map((field) => {
|
412
410
|
const newField = { ...field, mountingPath: field.slug };
|
413
411
|
if (options.mountingPath) {
|
414
412
|
newField.mountingPath = `${options.mountingPath}.${field.slug}`;
|
@@ -757,6 +755,32 @@ var replaceJSON = (key, value) => {
|
|
757
755
|
if (key === QUERY_SYMBOLS.EXPRESSION) return value.replaceAll(`'`, `''`);
|
758
756
|
return value;
|
759
757
|
};
|
758
|
+
var matchSelectedFields = (fields, pattern) => {
|
759
|
+
let regexStr = pattern.replace(/\./g, "\\.");
|
760
|
+
regexStr = regexStr.replace(/\*\*/g, "<<DOUBLESTAR>>");
|
761
|
+
regexStr = regexStr.replace(/\*/g, "[^.]*");
|
762
|
+
regexStr = regexStr.replace(/<<DOUBLESTAR>>/g, ".*");
|
763
|
+
const regex2 = new RegExp(`^${regexStr}$`);
|
764
|
+
return fields.filter((field) => regex2.test(field.slug));
|
765
|
+
};
|
766
|
+
var filterSelectedFields = (model, instruction) => {
|
767
|
+
if (!instruction) return model.fields;
|
768
|
+
let selectedFields = [];
|
769
|
+
for (const pattern of instruction) {
|
770
|
+
const isNegative = pattern.startsWith("!");
|
771
|
+
const cleanPattern = isNegative ? pattern.slice(1) : pattern;
|
772
|
+
const matchedFields = matchSelectedFields(
|
773
|
+
isNegative ? selectedFields : model.fields,
|
774
|
+
cleanPattern
|
775
|
+
);
|
776
|
+
if (isNegative) {
|
777
|
+
selectedFields = selectedFields.filter((field) => !matchedFields.includes(field));
|
778
|
+
} else {
|
779
|
+
selectedFields.push(...matchedFields);
|
780
|
+
}
|
781
|
+
}
|
782
|
+
return selectedFields;
|
783
|
+
};
|
760
784
|
var prepareStatementValue = (statementParams, value) => {
|
761
785
|
if (value === null) return "NULL";
|
762
786
|
if (!statementParams) {
|
package/package.json
CHANGED