@metaobjectsdev/migrate-ts 0.15.21-rc.1 → 0.16.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/diff/index.d.ts.map +1 -1
- package/dist/diff/index.js +141 -16
- package/dist/diff/index.js.map +1 -1
- package/dist/diff/status.js +28 -2
- package/dist/diff/status.js.map +1 -1
- package/dist/drift/drift.d.ts +2 -2
- package/dist/drift/drift.d.ts.map +1 -1
- package/dist/emit/postgres.d.ts.map +1 -1
- package/dist/emit/postgres.js +94 -4
- package/dist/emit/postgres.js.map +1 -1
- package/dist/expected-schema.d.ts +19 -2
- package/dist/expected-schema.d.ts.map +1 -1
- package/dist/expected-schema.js +26 -2
- package/dist/expected-schema.js.map +1 -1
- package/dist/introspect/postgres.d.ts +15 -1
- package/dist/introspect/postgres.d.ts.map +1 -1
- package/dist/introspect/postgres.js +132 -11
- package/dist/introspect/postgres.js.map +1 -1
- package/dist/snapshot/plan.d.ts +4 -3
- package/dist/snapshot/plan.d.ts.map +1 -1
- package/dist/snapshot/plan.js.map +1 -1
- package/dist/snapshot/serialize.d.ts +15 -1
- package/dist/snapshot/serialize.d.ts.map +1 -1
- package/dist/snapshot/serialize.js +15 -1
- package/dist/snapshot/serialize.js.map +1 -1
- package/dist/types.d.ts +95 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/view-column-types.d.ts +40 -0
- package/dist/view-column-types.d.ts.map +1 -0
- package/dist/view-column-types.js +100 -0
- package/dist/view-column-types.js.map +1 -0
- package/dist/view-fingerprint.d.ts +40 -0
- package/dist/view-fingerprint.d.ts.map +1 -0
- package/dist/view-fingerprint.js +88 -0
- package/dist/view-fingerprint.js.map +1 -0
- package/dist/view-sql-compare.d.ts.map +1 -1
- package/dist/view-sql-compare.js +24 -19
- package/dist/view-sql-compare.js.map +1 -1
- package/package.json +2 -2
- package/src/diff/index.ts +151 -19
- package/src/diff/status.ts +29 -2
- package/src/drift/drift.ts +2 -2
- package/src/emit/postgres.ts +102 -4
- package/src/expected-schema.ts +44 -3
- package/src/introspect/postgres.ts +148 -10
- package/src/snapshot/plan.ts +4 -3
- package/src/snapshot/serialize.ts +15 -1
- package/src/types.ts +109 -9
- package/src/view-column-types.ts +110 -0
- package/src/view-fingerprint.ts +97 -0
- package/src/view-sql-compare.ts +24 -19
package/src/view-sql-compare.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
// view-sql-compare.ts — the
|
|
1
|
+
// view-sql-compare.ts — the SQLITE/D1 comparator for view definition SQL.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// SCOPE — read this before reusing it. This comparator is sound ONLY on engines that
|
|
4
|
+
// store view SQL VERBATIM. SQLite and D1 do: `sqlite_master.sql` hands back the exact
|
|
5
|
+
// `CREATE VIEW <name> AS <body>` text we wrote, so normalizing away whitespace and the
|
|
6
|
+
// CREATE wrapper leaves two strings that genuinely can be equal.
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// `
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
8
|
+
// It is NOT usable on Postgres, and used to be. Postgres does not store view SQL — it
|
|
9
|
+
// stores the parse tree, and `pg_get_viewdef()` DEPARSES it back in Postgres's own
|
|
10
|
+
// style (lowercased functions, `LEFT OUTER JOIN` rewritten to `LEFT JOIN`,
|
|
11
|
+
// parenthesized FROM items and ON predicates, redundant aliases dropped). The text we
|
|
12
|
+
// emitted therefore NEVER comes back, this comparator returned false every single
|
|
13
|
+
// time, and `replace-view` fired on every migrate for every view, forever — while
|
|
14
|
+
// `verify --db` stayed permanently red for any project with a projection. Postgres now
|
|
15
|
+
// compares FINGERPRINTS instead (see view-fingerprint.ts), which never consults the
|
|
16
|
+
// deparser at all. Do not point this function at Postgres again.
|
|
14
17
|
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
18
|
+
// normalizeViewSql strips a leading `CREATE [OR REPLACE] VIEW <name> AS`, collapses
|
|
19
|
+
// whitespace runs, drops a trailing `;`, and lower-cases.
|
|
20
|
+
//
|
|
21
|
+
// CAVEAT (accepted tradeoff): lower-casing can mask a difference living ONLY in a
|
|
22
|
+
// case-sensitive string literal (e.g. `WHERE status = 'Active'` vs `'active'`), which
|
|
23
|
+
// an `origin.aggregate @filter` predicate can now carry. The fingerprint path
|
|
24
|
+
// deliberately does NOT lowercase for exactly this reason; this SQLite path keeps it
|
|
25
|
+
// for backwards-compatible behavior. The name regex matches one whitespace/`(`-free
|
|
26
|
+
// token, so a quoted view name containing a space would not strip cleanly — a non-issue
|
|
27
|
+
// for generated identifiers.
|
|
23
28
|
|
|
24
29
|
const CREATE_VIEW_PREFIX =
|
|
25
30
|
/^\s*create\s+(?:or\s+replace\s+)?(?:temp(?:orary)?\s+)?view\s+(?:if\s+not\s+exists\s+)?[^\s(]+(?:\s*\([^)]*\))?\s+as\s+/i;
|