query: filter since/until on effective date, not updated_at (#1706)

since/until range filters were applied against updated_at, so edited-but-old
entries leaked into time-bounded queries. Filter on the effective date instead.

Closes #1520

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
Matt Van Horn
2026-07-16 20:47:38 -07:00
committed by GitHub
co-authored by Matt Van Horn
parent 414940204a
commit d33aee843b
2 changed files with 27 additions and 9 deletions
+18
View File
@@ -94,12 +94,30 @@ describe('postgres-engine / search path timeout isolation', () => {
});
});
describe('postgres-engine / search date filtering', () => {
test('search paths filter since/until on effective_date before import-time fallback', () => {
const expectedDateExpr = 'COALESCE(p.effective_date, p.updated_at, p.created_at)';
const staleDatePredicate = /COALESCE\(p\.updated_at,\s*p\.created_at\)\s*[<>]\s*\$/;
for (const methodName of ['searchKeyword', 'searchKeywordChunks', 'searchVector']) {
const fn = stripComments(extractMethod(SRC, methodName));
expect(countOccurrences(fn, expectedDateExpr)).toBe(2);
expect(fn).not.toMatch(staleDatePredicate);
}
});
});
function stripComments(s: string): string {
return s
.replace(/\/\*[\s\S]*?\*\//g, '')
.replace(/(^|\s)\/\/[^\n]*/g, '$1');
}
function countOccurrences(s: string, needle: string): number {
return s.split(needle).length - 1;
}
// extractMethod grabs the body of a class method by brace-matching from
// its opening line. Returns the method body up to the matching closing
// brace. Good enough for the small number of methods in this file.