Skip to content

Commit

Permalink
Fix issue with BigInt64Array (#1892)
Browse files Browse the repository at this point in the history
Resolves issue #1890
  • Loading branch information
dfahlander committed Feb 5, 2024
1 parent 874d668 commit 1543bee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/functions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export function flatten<T> (a: (T | T[])[]) : T[] {

//https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
const intrinsicTypeNames =
"Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey"
"BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey"
.split(',').concat(
flatten([8,16,32,64].map(num=>["Int","Uint","Float"].map(t=>t+num+"Array")))
).filter(t=>_global[t]);
Expand Down
27 changes: 27 additions & 0 deletions test/tests-misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,30 @@ promisedTest("Issue - ReadonlyError thrown in liveQuery despite user did not do
`);
return F(ok, equal, Dexie, db, liveQuery).catch(err => ok(false, 'final catch: '+err));
});


promisedTest("Issue #1890 - BigInt64Array getting corrupted after an update", async () => {
if (typeof BigInt64Array === 'undefined') {
ok(true, "BigInt64Array not supported in browser");
return;
}
if (typeof Dexie.Observable?.version === 'string') {
ok(true, "Skipping this test - Dexie.Observable bails out from BigInts");
return;
}

await db.foo.put({
id: 1,
updated: Date.now(),
cols: [{
values: new BigInt64Array([1n, 2n])
}]
});
let val = await db.foo.get(1);
ok(val.cols[0].values instanceof BigInt64Array, "cols[0].values is a BigInt64Array");
await db.foo.update(1, {
updated: Date.now()
});
val = await db.foo.get(1);
ok(val.cols[0].values instanceof BigInt64Array, "cols[0].values is still a BigInt64Array after update");
});

0 comments on commit 1543bee

Please sign in to comment.