Skip to content

Commit 49e31fc

Browse files
committed
fix(service-analytics): look up retired operators the way the data door does
Plain table lookup over the constraint's $-keys (the package's lib has no Object.hasOwn), and drop an unused traversal parameter. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oAC7wmJvoM1VnnCjg
1 parent e8690bb commit 49e31fc

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎packages/services/service-analytics/src/strategies/filter-normalizer.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,10 +1969,10 @@ function assertBooleanNullFlags(node: unknown, path = 'where'): void {
19691969
* generic list {@link fieldLeaves} gives it.
19701970
*/
19711971
function retiredFilterOperatorError(op: string, field: string, siblings: readonly string[]): Error | null {
1972-
const guidance = Object.hasOwn(RETIRED_FILTER_OPERATORS, op) ? RETIRED_FILTER_OPERATORS[op] : undefined;
1972+
const guidance = RETIRED_FILTER_OPERATORS[op];
19731973
if (!guidance) return null;
19741974
const replacement = guidance.to ? ` Write "${guidance.to}" instead.` : '';
1975-
const alsoRetired = siblings.filter((key) => key !== op && Object.hasOwn(RETIRED_FILTER_OPERATORS, key));
1975+
const alsoRetired = siblings.filter((key) => key !== op && RETIRED_FILTER_OPERATORS[key]);
19761976
const also = alsoRetired.length
19771977
? ` The same field constraint also carries the retired ` +
19781978
`${alsoRetired.map((key) => `"${key}"`).join(', ')} — one "${guidance.to}" replaces the whole ` +
@@ -2004,9 +2004,11 @@ function retiredFilterOperatorError(op: string, field: string, siblings: readonl
20042004
* no retired operator name (`isFilterAST` refuses one before lowering).
20052005
*/
20062006
function assertNoRetiredOperators(node: unknown, path = 'where'): void {
2007-
forEachWhereFieldEntry(node, path, (key, spec, at) => {
2007+
forEachWhereFieldEntry(node, path, (key, spec) => {
20082008
if (!isFilterObject(spec)) return;
2009-
const ops = Object.keys(spec);
2009+
// Only `$`-keys reach the table: none of them is an `Object.prototype`
2010+
// member, so the plain lookup the data door's builders use is exact here.
2011+
const ops = Object.keys(spec).filter((k) => k.startsWith('$'));
20102012
for (const op of ops) {
20112013
const refusal = retiredFilterOperatorError(op, key, ops);
20122014
if (refusal) throw refusal;

0 commit comments

Comments
 (0)