fix: Tier 1 ship-blockers — packaging, pg value integrity, eager delete (v1.0.1) - #15
Merged
Conversation
…e) => v1.0.1 NEW-13: tsup splitting:true so import 'sql-switch' no longer hoists both drivers into the entry chunk => a single-engine install stops crashing on import. Drivers stay lazy, mode-gated chunks (optional-peer-dep invariant restored). Guarded by test/no-driver-hoist.test.ts on both ESM & CJS output. NEW-2: pg get() no longer double-parses jsonb (drizzle ran a second JSON.parse on pg's already-parsed value) => a snowflake-looking string like "123456789012345678" stops coming back as a precision-lost number. get/set/ delete now use the same raw $n::jsonb pool path as the scans & bulk upsert. NEW-7: set(null) stores a jsonb null on every path instead of a SQL NULL that the NOT NULL value column rejected on the forced path. C1: an un-awaited delete() now executes eagerly at call time (matching set()), and evicts any buffered set for the key so a later flush can't resurrect it. No public API changes, no breaking changes => patch release. drizzle-orm is still used for the SQLite driver & schema builders. Regression tests added: eager-delete (engine-agnostic), pg-json-roundtrip (pg-only), no-driver-hoist (dist guard). CHANGELOG updated; version bumped 1.0.0 => 1.0.1 in all 3 spots.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tier 1 correctness fixes. No public API changes and no breaking changes — safe as a patch release (
1.0.0→1.0.1).import 'sql-switch'no longer drags in both drivers. With tsupsplitting: false, esbuild inlined each lazily-imported driver into the entry chunk and hoisted its top-levelimport pg/import better-sqlite3, so a single-engine install crashed on import.splitting: truekeeps the drivers as their own chunks, loaded only once an engine is selected — restoring the optional-peer-dep invariant. Covered on both the ESM and CJS entrypoints.get()no longer corrupts JSON-looking strings.get()read through drizzle'sjsonbcolumn, running a secondJSON.parseon a value pg had already parsed, so a snowflake id"123456789012345678"came back as a precision-lost number and disagreed withentries()/scans on the same row.get/set/deletenow use the same raw parameterized$n::jsonbpool path as the bulk upsert and the scans, so every read/write path agrees byte-for-byte.set(null)is consistent across paths. drizzle mapped a JSnullonto SQLNULL, which theNOT NULL valuecolumn rejected on the forced path.setnow stores a jsonbnullon every path;get()reads it back asnullandhas()still reports the row.delete()now lands.delete()only did its work inside theWriteOperationcallbacks, so a fire-and-forgetdelete()silently did nothing while a fire-and-forgetset()committed. It now executes eagerly at call time (matchingset()) and evicts any buffered set for the key so a later flush can't resurrect it;await/.force()only decide whether you wait.drizzle-orm is still used for the SQLite driver and the schema builders, so it remains a dependency.
package.jsonpeer/optional deps are unchanged — no driver was promoted to a hard dependency.Tests added
test/no-driver-hoist.test.ts— dist guard: asserts neither built entrypoint (ESM + CJS) has a module-scope import/require ofpg/better-sqlite3. Proven to fail against asplitting: falsebuild.test/eager-delete.test.ts— engine-agnostic (KeyProxyover the in-memory fakedriver): un-awaited delete reaches the driver with the collector off and on, and evicts a buffered set. Proven to fail against a lazy delete.test/pg-json-roundtrip.test.ts— pg-only (skipIf(!DATABASE_URL), own throwaway schema per test): snowflake string stays a string &get()agrees with the scan, nested JSON-looking payloads survivebatchSet, andset(null)/batchSet(null)both store a jsonb null withexists()still true.Verification
pnpm checkandpnpm typecheckclean;pnpm docsat zero warnings.DATABASE_URL.exit-flush,idle-exit) fail only in this sandbox from a knownbetter-sqlite3native-ABI segfault; they exercise untouched machinery and are authoritative on CI (Node 22/24 ubuntu).Tier 2 (NEW-1 / NEW-5 cross-process safety) and Tier 3 are deliberately out of scope for this release.
🤖 Generated with Claude Code