GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sqlite: allow returning `ArrayBufferView`s from user-defined functions · nodejs/node@3999786

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • sqlite.md
  • src
    • node_sqlite.cc
  • test/parallel
    • test-sqlite-custom-functions.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/sqlite.md‎

Copy file name to clipboardExpand all lines: doc/api/sqlite.md
+7-7Lines changed: 7 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,13 @@ more data types than SQLite, only a subset of JavaScript types are supported.
500500
Attempting to write an unsupported data type to SQLite will result in an
501501
exception.
502502

503-
| SQLite | JavaScript |
504-
| --------- | -------------------- |
505-
| `NULL` | {null} |
506-
| `INTEGER` | {number} or {bigint} |
507-
| `REAL` | {number} |
508-
| `TEXT` | {string} |
509-
| `BLOB` | {Uint8Array} |
503+
| SQLite | JavaScript |
504+
| --------- | -------------------------- |
505+
| `NULL` | {null} |
506+
| `INTEGER` | {number} or {bigint} |
507+
| `REAL` | {number} |
508+
| `TEXT` | {string} |
509+
| `BLOB` | {TypedArray} or {DataView} |
510510

511511
## `sqlite.constants`
512512

Collapse file

‎src/node_sqlite.cc‎

Copy file name to clipboardExpand all lines: src/node_sqlite.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class UserDefinedFunction {
213213
} else if (result->IsString()) {
214214
Utf8Value val(isolate, result.As<String>());
215215
sqlite3_result_text(ctx, *val, val.length(), SQLITE_TRANSIENT);
216-
} else if (result->IsUint8Array()) {
216+
} else if (result->IsArrayBufferView()) {
217217
ArrayBufferViewContents<uint8_t> buf(result);
218218
sqlite3_result_blob(ctx, buf.data(), buf.length(), SQLITE_TRANSIENT);
219219
} else if (result->IsBigInt()) {
Collapse file

‎test/parallel/test-sqlite-custom-functions.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-sqlite-custom-functions.js
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,18 @@ suite('DatabaseSync.prototype.function()', () => {
274274
db.function('retString', () => { return 'foo'; });
275275
db.function('retBigInt', () => { return 5n; });
276276
db.function('retUint8Array', () => { return new Uint8Array([1, 2, 3]); });
277+
db.function('retArrayBufferView', () => {
278+
const arrayBuffer = new Uint8Array([1, 2, 3]).buffer;
279+
return new DataView(arrayBuffer);
280+
});
277281
const stmt = db.prepare(`SELECT
278282
retUndefined() AS retUndefined,
279283
retNull() AS retNull,
280284
retNumber() AS retNumber,
281285
retString() AS retString,
282286
retBigInt() AS retBigInt,
283-
retUint8Array() AS retUint8Array
287+
retUint8Array() AS retUint8Array,
288+
retArrayBufferView() AS retArrayBufferView
284289
`);
285290
assert.deepStrictEqual(stmt.get(), {
286291
__proto__: null,
@@ -290,6 +295,7 @@ suite('DatabaseSync.prototype.function()', () => {
290295
retString: 'foo',
291296
retBigInt: 5,
292297
retUint8Array: new Uint8Array([1, 2, 3]),
298+
retArrayBufferView: new Uint8Array([1, 2, 3]),
293299
});
294300
});
295301

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.