Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #322 +/- ##
=======================================
Coverage 85.56% 85.56%
=======================================
Files 9 9
Lines 2418 2418
Branches 510 510
=======================================
Hits 2069 2069
Misses 343 343
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rob-ghost
marked this pull request as ready for review
November 30, 2026 11:46
ref https://linear.app/ghost/issue/DYA-361 The parser read an unquoted number with parseInt, which drops everything after the decimal point, so `email_open_rate:<33.5` compared with 33 and left out the members whose open rate is exactly 33, and `email_open_rate:33.5` matched them. Ghost's members screen sends these: its email number filters accept a decimal, and a saved view kept the decimal text but compared with the whole number. A number is now read as written, so 33.5 is 33.5, 0.5 is 0.5 and 01.5 is 1.5. Whole numbers read as before, including 1.0 as 1 and 007 as 7, and what counts as a number doesn't change: a negative is still a negation, an exponent such as 1e5 is still text, a number ending in a point is still an error, and a number with more digits than a double holds is rounded as before.
rob-ghost
force-pushed
the
fix/dya-361-decimal-numbers
branch
from
November 30, 2026 12:21
bb79258 to
7627865
Compare
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/DYA-361
Problem
nql-langread an unquoted number withparseInt, which drops everything after the decimal point.email_open_rate:<33.5compared with 33, so it left out members whose open rate is exactly 33, andemail_open_rate:33.5matched them. Ghost's members screen sends these: its Emails sent, Emails opened and Open rate filters accept a decimal, and a saved view stored the decimal text but compared with the whole number.Solution
A number is read as written:
The lexer is unchanged, so what counts as a number is too. Only the value a decimal reads as changes:
33.5,33.25,0.5,01.51.0007-51e5'1e5''1e5'.5'.5''.5'1.dist/parser.jsis regenerated with the package's ownbuildscript. The only change in it is the one line that converts the number.What changes, for which filters
email_open_rate:<33.5,:33.5,:>33.5, and the same onemail_countandemail_opened_counttag:1.5and other decimals on a text column1-5(MySQL reads'1-5'as the number 1)Ghost
Ghost pins
nql-langandnqlthrough its catalog and overrides, so the bump reaches Admin's own parsing as well as Core. Admin then stops rewriting a reloaded33.5pill to 33. No Ghost code changes: no server-built filter uses a decimal, and no email recipient filter uses a number.Release
Each of the three filter fixes needs a minor version, since rows change for existing filters:
@tryghost/mongo-knex@tryghost/nql-lang@tryghost/nqlShip them in one run, after all three merge, so nql's ranges move to the new
mongo-knexandnql-lang:Leave out
--projectsand the run also takes@tryghost/mongo-utilsto 0.8.0, which has no changes, and moves nql's range to^0.8.0. Ghost pinsmongo-utils0.7.0 exactly, so it would then load two copies.A dry run of the command above (
pnpm exec nx release version minor --projects=… --dry-run) bumps exactly the three packages and moves both of nql's ranges.Ghost then bumps
mongo-knex,nqlandnql-langin one pull request. Its members pipeline callsmongo-knexdirectly, while posts and comments compile through nql's ownmongo-knex. Bumping one without the other runs two copies that disagree. That pull request also updates the two SQL strings thatghost/test/unit/server/models/post.test.jspins:posts.id != ?becomes(posts.id is null or posts.id != ?).Testing
Parser tests for decimals (one and two places), leading and trailing zeros, long digit strings, exponents and a trailing point. Rows on nql's members fixture, which gains an open rate column:
email_open_rate:<33.5now selects the member at 33. The decimal tests fail before this change.