Skip to content

fix(driver-memory,driver-mongodb): bare-day upper bounds cover the whole day (#4042) - #4048

Merged
os-zhuang merged 1 commit into
mainfrom
claude/dashboard-date-range-data-loss-b7qt5o
Jul 30, 2026
Merged

fix(driver-memory,driver-mongodb): bare-day upper bounds cover the whole day (#4042)#4048
os-zhuang merged 1 commit into
mainfrom
claude/dashboard-date-range-data-loss-b7qt5o

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Closes#4042#3777 / PR #4041(SQL 侧)的非 SQL 驱动对齐。

修正一处 issue 里的定位偏差

#4042 正文引用的 memory-matcher.ts 其实是只剩自身测试引用的遗留物(未从包入口导出)——find() 真正走 mingo,lowering 缝在 convertToMongoQuery / normalizeFieldOperators,与 driver-sql 的 where-builder 同构。修复落在那里;matcher 未动。

变更(共享 #4041nextUtcCalendarDay,规则逐格同表)

发射点变化
driver-memory mingo loweringMongo 形状 $lte/$between 与数组形状 <=/between:裸日期上界 → $lt 次日
driver-memory analytics cube-filterlte 同规则
driver-memory analytics dateRange 窗口半开 + 双存储形态桥接:窗口现在同时命中 ISO 字符串行(驱动自己的 created_at 默认形态、所有 REST/JSON 写入)与 Date 对象行 —— mingo 跨类型恒不匹配,单形态边界会静默清空另一半;$or 双拼写是 driver-sql D-B2 混合存储 CASE 修复的 schemaless 等价物(此前窗口只用 Date 比较值,字符串行整个不可见)
driver-mongodbtranslateFilter三种拼写($lte / $between / 数组 <=/lte)同规则

刻意不动#3777 语义表):完整 ISO/Date 比较值保持瞬时语义;$gte/$gt/$lt 保持午夜锚定。

实测依据

mingo 7.2 探针(修复前):ISO 字符串行上 $lte: '2026-07-28' 丢当天全部数据、$lt: '2026-07-29' 正确保留;Date 行对字符串比较值在所有操作符下不可见(含 $gte)——后者是存储形态问题而非边界语义,已按 Prime Directive #10 剥离为 #4047(含 mongo BSON Date 的对应缺口:mongo 上默认字段 created_at 是 BSON Date,字符串窗口整个为空,需要写路径收敛才能根治;translateFilter 层无字段类型信息,修不到)。

第五个求值面 @objectstack/formula.matchesFilterCondition(RLS 写侧 check,同样裸 <=)因层级约束(formula 不依赖 core)未在本 PR 对齐,已记入 #4047 关联段。

覆盖

测试

driver-memory 185 ✅(含新 7)/ driver-mongodb 100 ✅(含新 5);两包 turbo build(带 dts)✅;eslint 干净。既有断言零改动——memory-analytics 原有 dateRange 测试(Date 存储行)在双形态窗口下原样通过。

🤖 Generated with Claude Code

https://claude.ai/code/session_01EkL3RGJrzjLEGURsLxfS2f


Generated by Claude Code

…ole day (#4042)
The non-SQL half of #3777's calendar-day rule. Both drivers compiled a
bare YYYY-MM-DD $lte (and a between max) as-is, so on timestamp values
the window cut off at the final day's midnight — the dashboard
date-range filter's default configuration lost the current day exactly
as it did on SQL before #3777.
Both drivers now compile a bare-day upper bound half-open, sharing
nextUtcCalendarDay from @objectstack/core:
- driver-memory: the Mongo-style and array where spellings in the mingo
lowering ($lte/<= -> $lt next day; $between/between max the same), the
analytics cube-filter lte, and the analytics dateRange window — which
now also matches BOTH stored forms of a timestamp (ISO strings and
Date objects) instead of only Dates, since mingo compares cross-type
as never-equal (the $or of both spellings stands in for driver-sql's
mixed-storage CASE repair).
- driver-mongodb: the translateFilter lowering, all three spellings
($lte, $between, array <=/lte).
Unchanged per the #3777 semantics table: full-ISO/Date comparands keep
instant semantics; $gte/$gt/$lt keep their midnight anchoring. The
remaining cross-type storage-form gap (JS/BSON Date values invisible to
string comparands of every operator) is split out as #4047 — a
storage-form problem, not a bound-semantics one.
Tests: row-result probes on driver-memory (find: Mongo/array spellings,
$between, $or, invariance; analytics window over a mixed-form column)
and shape probes on the mongodb translator (all spellings, month
rollover, instant not widened).
Closes#4042
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EkL3RGJrzjLEGURsLxfS2f
@vercel

vercelBot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectstackIgnoredIgnoredJul 30, 2026 6:47am

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/m labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/driver-memory, @objectstack/driver-mongodb.

10 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/data-modeling/drivers.mdx(via @objectstack/driver-memory, @objectstack/driver-mongodb)
  • content/docs/deployment/vercel.mdx(via @objectstack/driver-memory)
  • content/docs/getting-started/glossary.mdx(via @objectstack/driver-memory, @objectstack/driver-mongodb)
  • content/docs/getting-started/your-first-project.mdx(via @objectstack/driver-memory)
  • content/docs/kernel/services-checklist.mdx(via @objectstack/driver-memory)
  • content/docs/permissions/authentication.mdx(via @objectstack/driver-memory)
  • content/docs/plugins/index.mdx(via @objectstack/driver-memory)
  • content/docs/plugins/packages.mdx(via @objectstack/driver-memory, @objectstack/driver-mongodb)
  • content/docs/protocol/objectql/query-syntax.mdx(via @objectstack/driver-memory, @objectstack/driver-mongodb)
  • content/docs/releases/implementation-status.mdx(via @objectstack/driver-memory, @objectstack/driver-mongodb)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

driver-memory / driver-mongodb:裸日期 $lte 上界在 datetime 值上同样丢当天数据(#3777 的非 SQL 驱动对齐)

2 participants

@os-zhuang@claude