(value: string)
| 290 | |
| 291 | /** @internal */ |
| 292 | export function normalizePartitionBound(value: string): string { |
| 293 | const normalized = normalizeWhitespace(value); |
| 294 | |
| 295 | if (!normalized) { |
| 296 | return ''; |
| 297 | } |
| 298 | |
| 299 | if (/^default$/i.test(normalized)) { |
| 300 | return 'default'; |
| 301 | } |
| 302 | |
| 303 | // Prepend `for values` if the caller passed a bare `with/in/from … to …` clause, then lowercase |
| 304 | // PG bound keywords outside quoted literals (so `FROM (MINVALUE) TO ('hello TO world')` becomes |
| 305 | // `from (minvalue) to ('hello TO world')` with the inner TO inside the literal preserved). |
| 306 | // PG's `pg_get_expr` emits `MINVALUE`/`MAXVALUE`/`NULL` in uppercase, so case-folding them here |
| 307 | // prevents a perpetual diff against user-supplied lowercase bounds. |
| 308 | const prefixed = /^for values\b/i.test(normalized) ? normalized : `for values ${normalized}`; |
| 309 | const lowered = mapOutsideLiterals(prefixed, segment => |
| 310 | segment.replace(PARTITION_BOUND_KEYWORDS, match => match.toLowerCase()), |
| 311 | ); |
| 312 | |
| 313 | return normalizePartitionSqlFragment(lowered); |
| 314 | } |
| 315 | |
| 316 | const createPartitionBound = (value: string): string => normalizePartitionBound(value); |
| 317 |
no test coverage detected