Repository navigation
fix(adapter-better-sqlite3): infer Bytes for Buffer values - #30913
EnesKartal wants to merge 1 commit into
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Infer and verify byte values packages/adapter-better-sqlite3/src/conversion.ts, packages/adapter-better-sqlite3/src/conversion.test.ts, packages/adapter-better-sqlite3/src/better-sqlite3.test.ts |
inferObjectType recognizes Uint8Array values as bytes. Tests check inference for buffer-like values, rejection of other objects, mapping Buffer values to Uint8Array, and results from an untyped BLOB expression. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: jkomyno
Merge Risk: 
Minimal · previous review f0ede
-
Untyped SQLite BLOBs are inferred as bytes. No merge-blocking risk is evident.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Issue [
#29868] requires byte inference for BLOB values returned as Buffer when no declared type exists.inferObjectTypenow acceptsUint8Array, which includesBuffer, and still acceptsArrayBuffer. The adapter test coversSELECT X'DEADBEEF' AS band assertsColumnTypeEnum.Bytesand the expected bytes. Conversion tests coverBuffer,Uint8Array, andArrayBuffer, and preserve rejection of unrelated objects.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
better-sqlite3 returns BLOBs as Buffer, a Uint8Array subclass, so inferObjectType threw UnexpectedTypeError for BLOBs from columns with no declared type (e.g. SELECT X'DEADBEEF'). Fixes prisma#29868 Signed-off-by: EnesKartal <eneskartal117@gmail.com>
f0ede9e to
c73601f
Compare
better-sqlite3 returns BLOBs as Buffer, but inferObjectType only accepted ArrayBuffer, so a BLOB in a column with no declared type (for example
SELECT X'DEADBEEF') threw UnexpectedTypeError. It now accepts Uint8Array too, which covers Buffer.Added conversion tests and an adapter test that runs the query from the issue on an in-memory database. They fail without the change. tsc, eslint and prettier are clean for the package. Unrelated: the UniqueConstraintViolation test in errors.test.ts failed before this change too (an extra "table" field in the output).
AI-assisted; I reviewed the change and the test results.
Fixes #29868
Summary by CodeRabbit