Fix PocketBase date query - use range operators not contains
All checks were successful
Deploy / deploy (push) Successful in 1m39s
All checks were successful
Deploy / deploy (push) Successful in 1m39s
The ~ contains operator doesn't work with PocketBase date fields. Use >= and < operators with YYYY-MM-DD format instead, matching the working /api/history pattern. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -517,18 +517,18 @@ describe("GET /api/today", () => {
|
||||
});
|
||||
|
||||
describe("dailyLog query", () => {
|
||||
it("queries dailyLogs with YYYY-MM-DD date format using contains operator", async () => {
|
||||
// PocketBase filters don't accept ISO format with T separator
|
||||
// Must use simple YYYY-MM-DD with ~ contains operator
|
||||
it("queries dailyLogs with YYYY-MM-DD date format using range operators", async () => {
|
||||
// PocketBase accepts simple YYYY-MM-DD in comparison operators
|
||||
// Use >= today and < tomorrow for exact day match
|
||||
currentMockUser = createMockUser();
|
||||
currentMockDailyLog = createMockDailyLog();
|
||||
|
||||
await GET(mockRequest);
|
||||
|
||||
// Verify filter uses YYYY-MM-DD format (2025-01-10) not ISO format
|
||||
// The filter should use ~ contains operator, not >= range
|
||||
// Verify filter uses YYYY-MM-DD format with range operators
|
||||
expect(lastDailyLogFilter).toBeDefined();
|
||||
expect(lastDailyLogFilter).toContain('date~"2025-01-10"');
|
||||
expect(lastDailyLogFilter).toContain('date>="2025-01-10"');
|
||||
expect(lastDailyLogFilter).toContain('date<"2025-01-11"');
|
||||
// Should NOT contain ISO format with T separator
|
||||
expect(lastDailyLogFilter).not.toContain("T");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user