Skip to content

🐛 Fixed member filters with multiple date based filters returning incorrect results#26458

Merged
cmraible merged 1 commit intomainfrom
renovate/nql-packages
Feb 18, 2026
Merged

🐛 Fixed member filters with multiple date based filters returning incorrect results#26458
cmraible merged 1 commit intomainfrom
renovate/nql-packages

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Feb 18, 2026

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:

  • 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. 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.

@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Feb 18, 2026
@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.08%. Comparing base (7fb2272) to head (77a039e).
⚠️ Report is 45 commits behind head on main.

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     
Flag Coverage Δ
admin-tests 53.70% <ø> (ø)
e2e-tests 73.08% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cmraible cmraible self-assigned this Feb 18, 2026
@cmraible
Copy link
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.

@cmraible cmraible changed the title Update dependency @tryghost/nql to v0.12.10 🐛 Fixed member filters with multiple date based filters returning incorrect results Feb 18, 2026
@cmraible cmraible merged commit f14c28f into main Feb 18, 2026
36 checks passed
@cmraible cmraible deleted the renovate/nql-packages branch February 18, 2026 19:59
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant