fix(driver-memory,driver-mongodb): bare-day upper bounds cover the whole day (#4042) - #4048
Merged
Merged
Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 10 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
July 30, 2026 06:56
This was referenced Jul 30, 2026
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.
Closes #4042。#3777 / PR #4041(SQL 侧)的非 SQL 驱动对齐。
修正一处 issue 里的定位偏差
#4042 正文引用的
memory-matcher.ts其实是只剩自身测试引用的遗留物(未从包入口导出)——find()真正走 mingo,lowering 缝在convertToMongoQuery/normalizeFieldOperators,与 driver-sql 的 where-builder 同构。修复落在那里;matcher 未动。变更(共享 #4041 的
nextUtcCalendarDay,规则逐格同表)driver-memorymingo lowering$lte/$between与数组形状<=/between:裸日期上界 →$lt 次日driver-memoryanalytics cube-filterlte同规则driver-memoryanalyticsdateRange窗口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行结果探针(dashboard 的日期区间上界打在datetime列上丢失当天数据 —— 默认配置即命中 #3777 复现形状,ISO 字符串存储):窗口保留整末日、完整 ISO 不放宽、$gte/$gt/$lt不变性、$between、$or分组、数组拼写;analytics 窗口在同列双形态夹具(ISO×3 + Date×4)上断言行数。driver-mongodb形状探针:三种拼写、月末翻转、瞬时不放宽、裸日期下界不动。测试
driver-memory185 ✅(含新 7)/driver-mongodb100 ✅(含新 5);两包turbo build(带 dts)✅;eslint 干净。既有断言零改动——memory-analytics原有 dateRange 测试(Date 存储行)在双形态窗口下原样通过。🤖 Generated with Claude Code
https://claude.ai/code/session_01EkL3RGJrzjLEGURsLxfS2f
Generated by Claude Code