8000 Merge pull request #158 from forestphoenix/master · NathanaelA/nativescript-sqlite@957d95d · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit 957d95d

Browse files
authored
Merge pull request #158 from forestphoenix/master
Fix in-memory databases on android
2 parents ef8de9b + 372dd55 commit 957d95d

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

demo/app/tests/dbAccess.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,17 @@ if (!sqlite.exists(dbName)) {
3434
});
3535

3636
});
37+
38+
new sqlite(":memory:", function(err, db) {
39+
describe('In-Memory Connection', function() {
40+
it('Error should be null', function() {
41+
assert.isNull(err);
42+
});
43+
it('dbConnection should not be null', function() {
44+
assert.isNotNull(db);
45+
});
46+
47+
done();
48+
});
49+
});
3750
});

demo/app/tests/dbAccessPromise.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,19 @@ describe('Database', function () {
3939
});
4040
});
4141
});
42+
43+
describe('In-Memory Connection', function () {
44+
var promise = new sqlite(":memory:");
45+
it('Promise should not be null', function () {
46+
assert.isNotNull(promise);
47+
});
48+
it('promise should work', function (done) {
49+
promise.then(function (db) {
50+
assert.isNotNull(db);
51+
52+
db.close();
53+
done();
54+
});
55+
});
56+
});
4257
});

src/sqlite.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ function Database(dbname, options, callback) {
354354
Database.prototype._openDatabase = function(dbName, flags) {
355355
if (dbName === ":memory:") {
356356
//noinspection JSUnresolvedVariable
357-
return android.database.sqlite.SQLiteDatabase.create(flags);
357+
return android.database.sqlite.SQLiteDatabase.create(null);
358358
} else {
359359
//noinspection JSUnresolvedVariable,JSUnresolvedFunction
360360
return android.database.sqlite.SQLiteDatabase.openDatabase(dbName, null, flags | 0x10000000);

0 commit comments

Comments
 (0)
0