@happyvertical/smrt-vitest 0.51.1 → 0.51.2

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/AGENTS.md CHANGED
@@ -116,6 +116,27 @@ the test transaction. Transaction handles are treated as already initialized
116
116
  by SMRT objects, so moving this provisioning into the transaction would leave
117
117
  the first interceptor-driven write without its required function (#2427).
118
118
 
119
+ The setup file's mocked `getDatabase()` also prechecks a PostgreSQL handle's
120
+ live schema before calling `syncSchema` (#2890): two constant-count queries
121
+ (`information_schema.columns` joined to `information_schema.tables` on
122
+ `table_type = 'BASE TABLE'` + `pg_indexes`, scoped to `current_schema()` —
123
+ never a literal `'public'`, since in-repo suites open handles against other
124
+ schemas via `search_path` — and batched across every registered table)
125
+ replace a per-column `SELECT EXISTS` round trip for every table on every
126
+ call, so a handle reopened against an already-provisioned database (a
127
+ per-test database name defeats the connection-URL-keyed
128
+ `preparedSchemasByConfig` cache) skips `syncSchema` entirely for tables that
129
+ already have every declared column and index. The `BASE TABLE` join matters
130
+ because `information_schema.columns` alone also lists a VIEW's columns; a
131
+ same-named view would otherwise satisfy the precheck (no `pg_indexes` rows
132
+ required) but cannot store rows. The precheck never runs on a
133
+ transactional handle (it would read un-savepointed, and PostgreSQL silently
134
+ no-ops every later statement on an aborted transaction) — `syncSchema` runs
135
+ for every table there, same as on any precheck failure on a non-transactional
136
+ handle, matching pre-#2890 behavior in both cases. Opt out per call with
137
+ `getDatabase({ ..., __smrtSkipVitestSchemaPreparation: true })`, or disable
138
+ automatic schema preparation globally with `SMRT_VITEST_AUTO_SCHEMA=0`.
139
+
119
140
  For local file-backed SQLite, identical schemas are prepared once per Vitest
120
141
  process and cloned from an immutable schema-only template for later databases.
121
142
  The cache key is the full generated DDL, concurrent first callers share one