Uh oh!
There was an error while loading. Please reload this page.
fix(tables): fix the filter on built in timestamp columns - #5972
fix(tables): fix the filter on built in timestamp columns#5972tusharmotwani1718 wants to merge 2 commits into
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The SQL filter builder now treats those names as real table columns: equality uses Reviewed by Cursor Bugbot for commit 56cb60b. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR redirects equality and range filters for built-in timestamp fields from JSON row data to PostgreSQL timestamp columns.
Confidence Score: 3/5This PR should not merge until built-in timestamp detection accepts the field names used by table filters. The UI and existing sort path use Files Needing Attention: apps/sim/app/api/table/utils.ts, apps/sim/lib/table/sql.ts
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/table/utils.ts | Adds built-in timestamp detection, but recognizes snake_case names while callers expose camelCase names. |
| apps/sim/lib/table/sql.ts | Routes recognized timestamp filters to physical columns, but the naming mismatch leaves the normal filter path unfixed and the helper import crosses from the shared library into the API layer. |
Reviews (1): Last reviewed commit: "fix[table-block]: fix filtering on built..." | Re-trigger Greptile
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| JsonValue, | ||
| Sort, | ||
| } from '@/lib/table/types' | ||
| import { isBuiltInDateField } from '../../app/api/table/utils' |
There was a problem hiding this comment.
Circular lib-app import
Medium Severity
isBuiltInDateField lives in app/api/table/utils.ts, which already imports buildFilterClause from @/lib/table, while lib/table/sql.ts now imports that helper back from the API utils module. That inverts the layering and creates a circular dependency between the SQL builder and the route utils.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit bc62aa7. Configure here.
…mn names consistent
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 56cb60b. Configure here.
| const cell = isBuiltInDateField(field) | ||
| ? sql.raw(`${tableName}.${field}`) | ||
| : sql.raw(`(${tableName}.data->>'${escapedField}')::${cast}`) |
There was a problem hiding this comment.
CamelCase fields hit wrong SQL columns
High Severity
isBuiltInDateField treats createdAt/updatedAt as built-in columns, then buildContainmentClause and buildComparisonClause interpolate that name via sql.raw into SQL. Postgres columns are created_at/updated_at, so camelCase filters resolve to a non-existent column and the query fails. The UI and sort path already use camelCase.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 56cb60b. Configure here.
There was a problem hiding this comment.
the columns created_at/updated_at exist by default in a table. while fetching rows by query_rows, they exist in row.created_at/row.updated_at not inside row.data.columnName as for normal columns.


Summary
Fixes filtering on the built-in timestamp columns (created_at and updated_at) in the Table block.
Previously, filters on these built-in columns incorrectly treated them as JSON fields, causing type validation errors or returning zero rows. This change queries the built-in PostgreSQL timestamp columns directly instead of the JSON data column.
Fixes#5920
Type of Change
Testing
Verified the fix by applying comparison filters ($gt, $gte, $lt, $lte, $eq) on the built-in created_at and updated_at columns and confirming that the expected rows are returned.
Also added/updated unit tests covering built-in timestamp column filtering.
Checklist
Screenshots/Videos
Before the fix, applying filters on the built-in timestamp columns (created_at, updated_at) resulted in validation errors:

Additionally, even when providing a Unix timestamp, the query returned zero rows because the filters were applied against the JSON data column instead of the built-in timestamp columns.