🐛 Fixed member filters with multiple date based filters returning incorrect results#26458
Merged
🐛 Fixed member filters with multiple date based filters returning incorrect results#26458
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26458 +/- ##
=======================================
Coverage 73.07% 73.08%
=======================================
Files 1538 1538
Lines 120209 120210 +1
Branches 14454 14457 +3
=======================================
+ Hits 87848 87859 +11
+ Misses 31358 31330 -28
- Partials 1003 1021 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Collaborator
|
This fixes a bug related to https://linear.app/ghost/issue/ONC-1446/member-filtering-issue; planning to write a better commit message and merge this in the morning. |
betschki
pushed a commit
to magicpages/Ghost
that referenced
this pull request
Feb 19, 2026
…orrect results (TryGhost#26458) ref https://linear.app/ghost/issue/ONC-1446/member-filtering-issue This commit updates @tryghost/nql to v0.12.10, which includes a [fix](TryGhost/NQL@9047935) for a bug in Ghost Admin's member filtering when more than one date based filter is applied. ## Summary When filtering members in Admin using the following filters, Ghost was returning members that should not have been included in the results: - Member status: paid - Stripe Subscription Status: active - Billing Period: Monthly - Next Billing Date: on or after Feb 1, 2026 - Next Billing Date: on or before Feb 28, 2026 The filtering was also order dependent - if you swapped the two filters on Billing Date, the results could be completely different. ## Root cause NQL would treat the above filters as two separate sub queries: 1. Member status: paid, subscription status: active, billing period: monthly, next billing date >= Feb 1, 2026 2. Next billing date <= Feb 28, 2026 The additional date-based filter was being split into its own subquery, such that any member with any subscription with a next billing date prior to Feb 28, 2026 would be included in the results - regardless of whether the matching subscription was active or billed monthly. The ordering was also important, because it's always the second condition that gets orphaned into its own subquery, and would return different results. ## Fix The fix for this bug was in NQL [here](TryGhost/NQL@9047935). Ultimately it ensures that range based filters, like our next billing date filter, are grouped into the same subquery, rather than split out into its own subquery. This prevents members with e.g. cancelled subscriptions with a next billing date in the past from being included in the example query above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref https://linear.app/ghost/issue/ONC-1446/member-filtering-issue
This commit updates @tryghost/nql to v0.12.10, which includes a fix for a bug in Ghost Admin's member filtering when more than one date based filter is applied.
Summary
When filtering members in Admin using the following filters, Ghost was returning members that should not have been included in the results:
The filtering was also order dependent - if you swapped the two filters on Billing Date, the results could be completely different.
Root cause
NQL would treat the above filters as two separate sub queries:
The additional date-based filter was being split into its own subquery, such that any member with any subscription with a next billing date prior to Feb 28, 2026 would be included in the results - regardless of whether the matching subscription was active or billed monthly. The ordering was also important, because it's always the second condition that gets orphaned into its own subquery, and would return different results.
Fix
The fix for this bug was in NQL here. Ultimately it ensures that range based filters, like our next billing date filter, are grouped into the same subquery, rather than split out into its own subquery. This prevents members with e.g. cancelled subscriptions with a next billing date in the past from being included in the example query above.