HF-85: Implement DCOUNT database function#1652
Open
marcin-kordas-hoc wants to merge 23 commits intodevelopfrom
Open
HF-85: Implement DCOUNT database function#1652marcin-kordas-hoc wants to merge 23 commits intodevelopfrom
marcin-kordas-hoc wants to merge 23 commits intodevelopfrom
Conversation
|
Task linked: HF-85 Implement function DCOUNT |
Performance comparison of head (9d07107) vs base (1852159) |
Add idiomatic code examples to React, Angular, Vue, and Svelte integration pages showing HyperFormula initialization and reading calculated values. Each guide uses framework-specific patterns (React hooks, Angular service, Vue ref/markRaw, Svelte reactivity). Closes HF-122.
Add new DatabasePlugin with DCOUNT(database, field, criteria) that counts numeric values in a specified field column for rows matching criteria. Supports field resolution by name (case-insensitive) and 1-based index, OR logic across criteria rows, AND logic within rows, and comparison operators in criteria values. Includes translations for all 17 languages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add three new database functions to DatabasePlugin with i18n translations for all 17 languages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove unnecessary type assertions in DAVERAGE, DMAX, DMIN methods. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New DatabasePlugin with shared helpers for the complete D-function family: DCOUNT, DSUM, DAVERAGE, DMAX, DMIN, DGET, DPRODUCT, DCOUNTA, DSTDEV, DSTDEVP, DVAR, DVARP. 169 tests across 12 test suites. All pass. 17 language translations per function. Excel validation: 152/152 PASS (verified in Excel Desktop). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…own-limitations.md - Add ### Database section with all 12 D-functions (DAVERAGE, DCOUNT, DCOUNTA, DGET, DMAX, DMIN, DPRODUCT, DSTDEV, DSTDEVP, DSUM, DVAR, DVARP) to built-in-functions.md in alphabetical order between Date and Engineering - Add Database to TOC and remove "database" from "yet to be supported" intro - Add nuance notes for DGET (#VALUE!/#NUM! error semantics) and DMAX/DMIN/DPRODUCT (return 0 when no records match) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c7dd75e to
18906bc
Compare
Introduce databaseFunctionParameters constant and withDatabaseArgs() helper to eliminate repeated field/criteria resolution across all 12 database functions. Reduces file from 725 to 533 lines with no behavioral changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove "(consistent with Excel behavior)" from known-limitations.md per review guideline: describe HF behavior only, no Excel references - Remove trailing space in collectNumericValues Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Addresses Cursor Bugbot findings on PR #1652: - csCZ.ts: DCOUNT was English 'DCOUNT' instead of localized 'DPOCET' (consistent with DCOUNTA = 'DPOCET2') - resolveFieldIndex: coerce boolean field arg to number (TRUE -> 1, FALSE -> 0) per Excel convention, matching ArithmeticHelper semantics Regression test added in hyperformula-tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use Number.isFinite to reject NaN and Infinity before the bounds check — the previous `index < 1 || index > headers.length` comparison silently returns false for NaN, which would let a NaN index through and produce incorrect results. Addresses Cursor Bugbot finding. Regression test added in hyperformula-tests.
SCALAR argument types do not auto-propagate CellError in the framework (coerceArgumentsToRequiredTypes skips propagation for SCALAR), so the raw error reaches resolveFieldIndex and buildDatabaseCriteria. Both sites used to fall through into generic #VALUE! / BadCriterion, discarding the original error type. Now both check for CellError upfront and return it verbatim, preserving #DIV/0!, #NUM!, etc. — matching Excel's error-propagation behavior. Addresses Cursor Bugbot finding. Regression tests added in hyperformula-tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Dutch translation had a triple A typo — DCOUNT is DBAANTAL and the COUNTA variant with C suffix should be DBAANTALC. Addresses Cursor Bugbot finding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous value lacked the D prefix and reversed the word order. Verified against Microsoft Support's official Norwegian Excel reference: DCOUNT → DANTALL. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
isExtendedNumber silently skipped CellError values, letting numeric aggregation D-functions return a clean number even when a matching field cell contained #DIV/0! / #N/A / etc. Excel propagates the error instead. Each of DSUM, DPRODUCT, DAVERAGE, DMAX, DMIN now returns the error immediately when encountered. collectNumericValues (shared by DSTDEV, DSTDEVP, DVAR, DVARP) now returns CellError | number[] so those four propagate too. DCOUNT, DCOUNTA, and DGET are unchanged — COUNT-family semantics in Excel do not propagate field errors, and DGET already returns the cell verbatim. Regression test added in hyperformula-tests. Addresses Cursor Bugbot finding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extends the CellError propagation introduced in 947a9fd to DCOUNT and DCOUNTA. This keeps all 12 D-functions consistent: a matching field cell containing an error surfaces the error with its original type rather than being silently skipped or counted. Addresses Cursor Bugbot findings. Regression tests added in hyperformula-tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- plPL: DCOUNTA 'BD.ILE.REKORDOW.A' -> 'BD.ILE.REKORDÓW.A' (missing Ó, matches DCOUNT pattern; Cursor Bugbot finding). - plPL: DAVERAGE 'BD.SREDNIA' -> 'BD.ŚREDNIA' (missing Ś, per Microsoft Polish documentation; pre-emptive fix for the same class of issue). - DGET: explicit CellError check on the matched cell makes the error- propagation path consistent with the other D-functions (previously worked by accident via fall-through). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4e73545. Configure here.
… docs Proactive audit against Microsoft's official localized Excel documentation (https://support.microsoft.com/{lang}/office/...) caught systemic mismatches beyond what Cursor Bugbot had flagged so far. Czech (csCZ) — 7 corrections (diacritics + DSUM word): - DAVERAGE DPRUMER -> DPRŮMĚR - DCOUNT DPOCET -> DPOČET - DCOUNTA DPOCET2 -> DPOČET2 - DGET DZISKAT -> DZÍSKAT - DPRODUCT DSOUCIN -> DSOUČIN - DSTDEV DSMODCH.VYBER -> DSMODCH.VÝBĚR - DSUM DSOUCET -> DSUMA (entire word was wrong) - DVAR DVAR.VYBER -> DVAR.VÝBĚR Turkish (trTR) — 11 corrections (VSEÇ prefix across the family): - DAVERAGE VORTALAMA -> VSEÇORT - DCOUNT VSAY -> VSEÇSAY - DCOUNTA VSAYMA -> VSEÇSAYDOLU - DMAX VMAKS -> VSEÇMAK - DMIN VMİN -> VSEÇMİN - DPRODUCT VÇARPIM -> VSEÇÇARP - DSTDEV VSTDSAPMA -> VSEÇSTDSAPMA - DSTDEVP VSTDSAPMAP -> VSEÇSTDSAPMAS - DSUM VTOPLA -> VSEÇTOPLA - DVAR VVAR -> VSEÇVAR - DVARP VVARP -> VSEÇVARS (DGET stays as VAL — Microsoft Turkish keeps the short form.) Danish (daDK) — 3 corrections: - DAVERAGE DGENNEMSNIT -> DMIDDEL - DCOUNT ANTAL.DB -> DTÆL - DCOUNTA ANTAL.DBV -> DTÆLV Portuguese (ptPT) — 3 corrections: - DCOUNTA BDCONTARA -> BDCONTAR.VAL - DGET BDEXTRAIR -> BDOBTER - DPRODUCT BDPRODUTO -> BDMULTIPL All 24 changes verified directly against Microsoft's support pages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The defensive CellError guard added earlier returned the error as soon as a matching row with a field error was seen, even when more rows also matched. Excel's DGET resolves the "multiple matches → #NUM!" check first and only surfaces field errors when exactly one record matches. Move the CellError check to after the loop so the match count is finalised first. Addresses Cursor Bugbot finding. Regression tests added in hyperformula-tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1652 +/- ##
===========================================
+ Coverage 96.77% 97.15% +0.38%
===========================================
Files 174 175 +1
Lines 15086 15316 +230
Branches 3223 3286 +63
===========================================
+ Hits 14599 14880 +281
+ Misses 487 436 -51
🚀 New features to boost your workflow:
|
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.

Context
Implements all 12 Excel database functions (D-functions family). Originally scoped to DCOUNT only, expanded to the full family since all share the same infrastructure (field resolution, criteria parsing, row matching).
How did you test your changes?
Types of changes
Related issues:
Checklist:
Summary
DatabasePlugin(533 lines) with shared infrastructurebuilt-in-functions.md(Database section),known-limitations.md(Nuances)Implementation
withDatabaseArgs()helper eliminates boilerplate across all 12 functionsresolveFieldIndex()— string (case-insensitive header match) or 1-based numeric index withMath.trunc()buildDatabaseCriteria()— OR across rows, AND within row, reusesCriterionBuilderrowMatchesCriteria()—.some()(OR) +.every()(AND)collectNumericValues()— shared by DSTDEV/DSTDEVP/DVAR/DVARPExcel behavior edge cases
Linked
Note
Medium Risk
Adds a new interpreter plugin and criteria/field parsing logic that affects formula evaluation and error semantics, which could introduce edge-case regressions in calculations.
Overview
Implements the Excel database function family by adding a new
DatabasePluginwithDAVERAGE,DCOUNT,DCOUNTA,DGET,DMAX,DMIN,DPRODUCT,DSTDEV,DSTDEVP,DSUM,DVAR, andDVARP, including shared field resolution and criteria parsing/matching.Updates public-facing docs to list the new Database function category and function semantics, adds basic integration examples for Angular/React/Svelte/Vue, and extends i18n language packs with localized names for all new functions. Also records the addition in
CHANGELOG.mdand notes key behavioral nuances inknown-limitations.md.Reviewed by Cursor Bugbot for commit 9d07107. Bugbot is set up for automated code reviews on this repo. Configure here.