Skip to content

Commit ea18f15

Browse files
committed
no-mistakes(review): apply reviewer inline fixes
1 parent 03b6ad4 commit ea18f15

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ here.**
2727
literal's `::text` was already folded away but the column's was not, so a database `migrate`
2828
had just built showed the same constraint as both added and dropped. The comparison now
2929
drops a `::text` cast only when it sits directly before a regex-match operator (`~`, `~*`,
30-
`!~`, `!~*`), where the uncast spelling is the only valid one; a changed pattern or any
31-
other cast still reads as drift. Schema comparison is TypeScript-owned, so no other port
30+
`!~`, `!~*`), whatever the column type; a changed pattern or any other cast still reads as
31+
drift. Known gap: on a `citext` column the cast and uncast spellings differ in meaning
32+
(case-sensitive vs case-insensitive) but compare equal. Schema comparison is TypeScript-owned, so no other port
3233
carries this comparison.
3334

3435
- **The api reference now follows a routes generator's `filter` as well as its `expose`.**

‎server/typescript/packages/migrate-ts/src/check-expr-compare.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,11 @@ function readCastTarget(s: string, i: number): { type: string; consumed: number
195195
function isElidableCast(type: string, lhs: string, rest: string): boolean {
196196
// `::text` directly before a regex-match operator (`~`, `~*`, `!~`, `!~*`). Those
197197
// operators are defined on text, so on a varchar/text column PG adds the cast itself
198-
// (`"key" ~ '…'` comes back `((key)::text ~ '…'::text)`), and on any other column type
199-
// the uncast spelling is not valid SQL — so a cast here is never the author's meaning.
198+
// (`"key" ~ '…'` comes back `((key)::text ~ '…'::text)`). The comparator sees only the
199+
// expression string, never the column type, so this elides the cast for every column.
200+
// Known gap: on a `citext` column `col::text ~ 'A'` (case-sensitive) and `col ~ 'A'`
201+
// (citext's own case-insensitive operator) both normalize alike, so switching between
202+
// the two spellings reads as clean.
200203
if (type === "text" && /^\s*!?~\*?(?![-+*\/<>=~!@#%^&|?])/.test(rest)) return true;
201204
// `->>` / `#>>` yield text; a following `::text` cannot change anything.
202205
if (type === "text" && /(?:->>|#>>)\s*(?:'(?:[^']|'')*'|[\w."]+)$/.test(lhs)) return true;

0 commit comments

Comments
 (0)