@ronin/compiler 0.16.1 → 0.16.2

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -10
  2. 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") && !single && instructions?.limitedTo) {
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(model, statementParams, {
748
- before: instructions.before,
749
- after: instructions.after,
750
- with: instructions.with,
751
- orderedBy: instructions.orderedBy,
752
- limitedTo: instructions.limitedTo
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {