mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1336944 - Change Sqlite.jsm to bind TypedArrays as Blobs, not common Arrays. r=Gijs
Currently an Array is bound as a blob. Unfortunately this occupies the best javascript code path to bind an array to an IN clause in the future. We would like Arrays to bind to IN lists, while still keeping a nice interface to bind blobs. This patch makes Uint8Array bind to blob, while Array is left available for future use. MozReview-Commit-ID: 7xzumBs8JTe --HG-- extra : rebase_source : e9f63f06892d9db801951243648eddd148646426
This commit is contained in:
parent
7a50a4d668
commit
f8239567d1
@ -80,7 +80,7 @@ var crypto = new OSCrypto();
|
||||
var dbConn;
|
||||
|
||||
function promiseSetPassword(login) {
|
||||
let passwordValue = crypto.stringToArray(crypto.encryptData(login.password));
|
||||
let passwordValue = new Uint8Array(crypto.stringToArray(crypto.encryptData(login.password)));
|
||||
return dbConn.execute(`UPDATE logins
|
||||
SET password_value = :password_value
|
||||
WHERE rowid = :rowid
|
||||
|
@ -680,7 +680,8 @@ ConnectionData.prototype = Object.freeze({
|
||||
}
|
||||
|
||||
function bindParam(obj, key, val) {
|
||||
let isBlob = Array.isArray(val);
|
||||
let isBlob = val && typeof val == "object" &&
|
||||
val.constructor.name == "Uint8Array";
|
||||
let args = [key, val].concat(isBlob ? [val.length] : []);
|
||||
let methodName =
|
||||
`bind${isBlob ? "Blob" : ""}By${typeof key == "number" ? "Index" : "Name"}`;
|
||||
|
@ -1103,7 +1103,7 @@ add_task(function* test_datatypes() {
|
||||
null_col: null,
|
||||
integer_col: 12345,
|
||||
text_col: "qwerty",
|
||||
blob_col: new Array(256).fill(undefined).map( (value, index) => index % 256 ),
|
||||
blob_col: new Uint8Array(256).map( (value, index) => index % 256 ),
|
||||
real_col: 3.14159265359,
|
||||
numeric_col: true
|
||||
},
|
||||
@ -1111,7 +1111,7 @@ add_task(function* test_datatypes() {
|
||||
null_col: null,
|
||||
integer_col: -12345,
|
||||
text_col: "",
|
||||
blob_col: new Array(256 * 2).fill(undefined).map( (value, index) => index % 256 ),
|
||||
blob_col: new Uint8Array(256 * 2).map( (value, index) => index % 256 ),
|
||||
real_col: Number.NEGATIVE_INFINITY,
|
||||
numeric_col: false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user