* Validates that a range-operator value matches its column's expected JS type * before it reaches Postgres. Surfaces an actionable, column-named error at the * SQL builder layer instead of a generic `invalid input syntax for type numeric` * from the database.
( field: string, columnType: ColumnType | undefined, cast: 'numeric' | 'timestamptz', value: number | string )
| 267 | * from the database. |
| 268 | */ |
| 269 | function validateComparisonValue( |
| 270 | field: string, |
| 271 | columnType: ColumnType | undefined, |
| 272 | cast: 'numeric' | 'timestamptz', |
| 273 | value: number | string |
| 274 | ): void { |
| 275 | if (cast === 'numeric' && typeof value !== 'number') { |
| 276 | const label = columnType ?? 'number' |
| 277 | throw new TableQueryValidationError( |
| 278 | `Range operator on column "${field}" (${label}) requires a number, got ${typeof value}` |
| 279 | ) |
| 280 | } |
| 281 | if (cast === 'timestamptz' && typeof value !== 'string') { |
| 282 | throw new TableQueryValidationError( |
| 283 | `Range operator on column "${field}" (date) requires a date string, got ${typeof value}` |
| 284 | ) |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Builds SQL conditions for a single field based on the provided condition. |
no outgoing calls
no test coverage detected