@ronin/compiler 0.16.1 → 0.16.2-leo-ron-1099-1-experimental-368
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 +18 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -174,7 +174,7 @@ var generatePaginationCursor = (model, orderedBy, record) => {
|
|
174
174
|
};
|
175
175
|
|
176
176
|
// src/instructions/before-after.ts
|
177
|
-
var handleBeforeOrAfter = (model, statementParams, instructions) => {
|
177
|
+
var handleBeforeOrAfter = (model, statementParams, queryType, instructions) => {
|
178
178
|
if (!(instructions.before || instructions.after)) {
|
179
179
|
throw new RoninError({
|
180
180
|
message: "The `before` or `after` instruction must not be empty.",
|
@@ -187,7 +187,7 @@ var handleBeforeOrAfter = (model, statementParams, instructions) => {
|
|
187
187
|
code: "MUTUALLY_EXCLUSIVE_INSTRUCTIONS"
|
188
188
|
});
|
189
189
|
}
|
190
|
-
if (!instructions.limitedTo) {
|
190
|
+
if (!instructions.limitedTo && queryType !== "count") {
|
191
191
|
let message = "When providing a pagination cursor in the `before` or `after`";
|
192
192
|
message += " instruction, a `limitedTo` instruction must be provided as well, to";
|
193
193
|
message += " define the page size.";
|
@@ -724,7 +724,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
724
724
|
);
|
725
725
|
if (withStatement.length > 0) conditions.push(withStatement);
|
726
726
|
}
|
727
|
-
if ((queryType === "get" || queryType === "count"
|
727
|
+
if (!single && (queryType === "get" && instructions?.limitedTo || queryType === "count" && (instructions?.before || instructions?.after))) {
|
728
728
|
instructions = instructions || {};
|
729
729
|
instructions.orderedBy = instructions.orderedBy || {};
|
730
730
|
instructions.orderedBy.ascending = instructions.orderedBy.ascending || [];
|
@@ -744,13 +744,18 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
744
744
|
queries: [query]
|
745
745
|
});
|
746
746
|
}
|
747
|
-
const beforeAndAfterStatement = handleBeforeOrAfter(
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
747
|
+
const beforeAndAfterStatement = handleBeforeOrAfter(
|
748
|
+
model,
|
749
|
+
statementParams,
|
750
|
+
queryType,
|
751
|
+
{
|
752
|
+
before: instructions.before,
|
753
|
+
after: instructions.after,
|
754
|
+
with: instructions.with,
|
755
|
+
orderedBy: instructions.orderedBy,
|
756
|
+
limitedTo: instructions.limitedTo
|
757
|
+
}
|
758
|
+
);
|
754
759
|
conditions.push(beforeAndAfterStatement);
|
755
760
|
}
|
756
761
|
if (conditions.length > 0) {
|
@@ -816,7 +821,8 @@ var filterSelectedFields = (model, instruction) => {
|
|
816
821
|
var prepareStatementValue = (statementParams, value) => {
|
817
822
|
if (value === null) return "NULL";
|
818
823
|
if (!statementParams) {
|
819
|
-
|
824
|
+
if (typeof value === "string") return `'${value}'`;
|
825
|
+
const valueString = typeof value === "object" ? `json('${JSON.stringify(value, replaceJSON)}')` : value.toString();
|
820
826
|
return valueString;
|
821
827
|
}
|
822
828
|
let formattedValue = value;
|
@@ -854,7 +860,7 @@ var composeFieldValues = (models, model, statementParams, instructionName, value
|
|
854
860
|
);
|
855
861
|
const collectStatementValue = options.type !== "fields";
|
856
862
|
const symbol = getQuerySymbol(value);
|
857
|
-
let conditionMatcher = "=";
|
863
|
+
let conditionMatcher = instructionName === "to" ? "=" : getMatcher(value, false);
|
858
864
|
let conditionValue = value;
|
859
865
|
if (options.condition) {
|
860
866
|
[conditionMatcher, conditionValue] = WITH_CONDITIONS[options.condition](value);
|