HF-85: Implement all database functions#1652
HF-85: Implement all database functions#1652marcin-kordas-hoc wants to merge 27 commits intodevelopfrom
Conversation
|
Task linked: HF-85 Implement function DCOUNT |
Performance comparison of head (74c4397) vs base (8b525cb) |
c7dd75e to
18906bc
Compare
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>
|
|
||
| For more details, see the [client-side installation](client-side-installation.md) section. | ||
|
|
||
| ## Basic usage |
There was a problem hiding this comment.
The framework integration guides should not be modified in this PR
There was a problem hiding this comment.
Reverted in commit 0c3decd04 — framework integration guide changes were out of scope for HF-85 (D-functions). The corresponding HF-122 PR #1653 ships the actual framework guides.
| * DGET returns `#VALUE!` when no records match the criteria, and `#NUM!` when more than one record matches. | ||
| * DMAX, DMIN, and DPRODUCT return `0` when no records match the criteria. |
There was a problem hiding this comment.
why is it listed as limitations? Is it different to what Excel does?
There was a problem hiding this comment.
Agreed — DGET / DMAX / DMIN / DPRODUCT behaviors match Excel exactly (DGET returns #VALUE! for no match, #NUM! for multiple matches; DMAX/DMIN/DPRODUCT return 0 when no match). They are not HyperFormula deviations and do not belong in known-limitations.md. Removed in commit 465321fd7.
| DB: 'DB', | ||
| DAVERAGE: 'TKESKIARVO', | ||
| DCOUNT: 'TLASKE', | ||
| DCOUNTA: 'TLASKE.A', |
There was a problem hiding this comment.
Finnish DCOUNTA translation has incorrect dot separator
Medium Severity
The Finnish translation for DCOUNTA is 'TLASKE.A' (with a dot), but the correct Excel Finnish function name is 'TLASKEA' (without a dot). Users typing the correct Finnish name won't get the function recognized, and the registered name doesn't match Excel Desktop.
Reviewed by Cursor Bugbot for commit 465321f. Configure here.
There was a problem hiding this comment.
False positive — Finnish Excel uses dot syntax in function names (e.g., LASKE.A for COUNTA, KESKIARVO.JOS for AVERAGEIF, LASKE.TYHJÄT for COUNTBLANK). TLASKE.A for DCOUNTA is consistent with this convention and matches Microsoft's official Finnish translation. The dot is intentional, not a separator typo.
✅ Deploy Preview for hyperformula-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fae8844. Configure here.
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>
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>
… 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>
Per sequba review: DGET returning #VALUE! / #NUM! and DMAX/DMIN/DPRODUCT returning 0 for no-match are Excel-identical behaviors, not HyperFormula deviations. They do not belong in known-limitations.md. The SEQUENCE/FILTER parse-time-dimensions bullet remains — that one is a HyperFormula-specific limitation.
Per Microsoft Excel Russian translations, DCOUNTA is БСЧЁТА (with Ё, not Е). The pattern is consistent with COUNT (СЧЁТ), COUNTA (СЧЁТЗ), and DCOUNT (БСЧЁТ) which all use Ё. The previous БСЧЕТА was a typo missing the ё diacritical mark. Cursor Bugbot finding (real bug, not historical re-flag — verified by cross-referencing with COUNT/COUNTA/DCOUNT existing translations and Microsoft Excel Russian docs convention).
Per Cursor Bugbot review and Excel behavior — when a criteria header cell evaluates to a CellError (e.g., #REF!, #DIV/0!), the D-function should return that error rather than silently mapping the column to -1 and continuing. This aligns the header-cell behavior with the data cell behavior at the same location (lines 535-537), which already propagated CellError.
fae8844 to
74c4397
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1652 +/- ##
===========================================
- Coverage 97.18% 97.16% -0.03%
===========================================
Files 174 175 +1
Lines 15086 15319 +233
Branches 3223 3287 +64
===========================================
+ Hits 14662 14884 +222
- Misses 424 435 +11
🚀 New features to boost your workflow:
|


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 new interpreter functionality that affects formula evaluation semantics (criteria parsing, error handling, and aggregation behavior), though changes are largely additive and isolated to a new plugin plus docs/i18n updates.
Overview
Adds a new
DatabasePluginimplementing the 12 Excel database functions (DCOUNT,DCOUNTA,DSUM,DAVERAGE,DMAX,DMIN,DGET,DPRODUCT,DSTDEV,DSTDEVP,DVAR,DVARP), including shared logic for field resolution, criteria parsing, row matching, and Excel-like error propagation.Updates the public surface by exporting the plugin, adding translations for these functions across language packs, and expanding docs/CHANGELOG to include a new Database functions category and function list.
Reviewed by Cursor Bugbot for commit 74c4397. Bugbot is set up for automated code reviews on this repo. Configure here.