-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support SQL blob marshaling using ArrayBuffer and Base64.
Web SQL doesn't actually support storing binary data in SQL blobs using the SQLite blob methods. It serializes binary data using strings with the SQLite text methods which results in data not being stored as a blob. This can be problematic in Cordova if you need to work with existing SQLite databases. This change adds more robust support for binary serialization. ArrayBuffer values can be used in statements and these will be converted to a `sqlblob` URI with base64 data that is unpacked on the native side and stored as a proper binary blob. When reading a blob back from the native side, the previous behavior was to return the blob as base64. Now, the blob is returned as a `sqlblob` object which can then be unpacked in JavaScript to base64, ArrayBuffer, or binary string. tx.executeSql("SELECT foo FROM test_table", [], function(tx, res) { var blob = res.rows.item(0).foo; if (blob.isBlob) { blob.toBase64(); blob.toBinaryString(); blob.toArrayBuffer(); } }); Tests were added to verify the behavior and to demonstrate usage. Only iOS and Android were updated. Windows Phone did not previously have blob support; saving for a future update.
- Loading branch information
1 parent
69163dc
commit ec00c6a
Showing
5 changed files
with
285 additions
and
165 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.