Skip to content

Commit 0db5ff6

Browse files
committed
Add test for issue #55
issue #55 is now confirmed
1 parent 48356e4 commit 0db5ff6

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

test/issue55.db

149 KB
Binary file not shown.

test/test_issue55.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
exports.test = function(sql, assert) {
2-
// Create a database
3-
var db = new sql.Database();
4-
db.run("CREATE TABLE foobar (value)");
5-
var expectedCount = 100;
6-
for (var i=0; i<expectedCount; i++) {
7-
db.run("INSERT INTO foobar VALUES ("+i+")");
8-
}
2+
var fs = require('fs');
3+
var path = require('path');
4+
5+
var filebuffer = fs.readFileSync(path.join(__dirname, 'issue55.db'));
6+
7+
//Works
8+
var db = new SQL.Database(filebuffer);
9+
10+
var origCount = db.prepare("SELECT COUNT(*) AS count FROM networklocation").getAsObject({}).count;
11+
12+
db.run("INSERT INTO networklocation (x, y, network_id, floor_id) VALUES (?, ?, ?, ?)", [123, 123, 1, 1]);
13+
var count = db.prepare("SELECT COUNT(*) AS count FROM networklocation").getAsObject({}).count;
14+
assert.equal(count, origCount + 1, "The row has been inserted");
15+
916
var dbCopy = new sql.Database(db.export());
10-
var count = db.exec("SELECT COUNT(*) FROM foobar")[0].values[0][0];
11-
assert.equal(count, expectedCount, "export and reimport copies all the data");
17+
var newCount = dbCopy.prepare("SELECT COUNT(*) AS count FROM networklocation").getAsObject({}).count;
18+
assert.equal(newCount, count, "export and reimport copies all the data");
19+
console.log(origCount, count, newCount);
1220
};
1321

1422
if (module == require.main) {

0 commit comments

Comments
 (0)