Commit 5bad8878 by Tom Hughes

Make sure the INSERT completes before trying the SELECT

parent 113c3719
......@@ -17,23 +17,27 @@ describe('data types', function() {
it('should serialize Date()', function(done) {
var date = new Date();
db.run("INSERT INTO int_table VALUES(?)", date);
db.run("INSERT INTO int_table VALUES(?)", date, function (err) {
if (err) throw err;
db.get("SELECT int FROM int_table", function(err, row) {
if (err) throw err;
assert.equal(row.int, +date);
done();
});
});
});
it('should serialize RegExp()', function(done) {
var regexp = /^f\noo/;
db.run("INSERT INTO txt_table VALUES(?)", regexp);
db.run("INSERT INTO txt_table VALUES(?)", regexp, function (err) {
if (err) throw err;
db.get("SELECT txt FROM txt_table", function(err, row) {
if (err) throw err;
assert.equal(row.txt, String(regexp));
done();
});
});
});
[
4294967296.249,
......@@ -49,7 +53,8 @@ describe('data types', function() {
-Infinity
].forEach(function(flt) {
it('should serialize float ' + flt, function(done) {
db.run("INSERT INTO flt_table VALUES(?)", flt);
db.run("INSERT INTO flt_table VALUES(?)", flt, function (err) {
if (err) throw err;
db.get("SELECT flt FROM flt_table", function(err, row) {
if (err) throw err;
assert.equal(row.flt, flt);
......@@ -57,6 +62,7 @@ describe('data types', function() {
});
});
});
});
[
4294967299,
......@@ -70,7 +76,8 @@ describe('data types', function() {
-Infinity
].forEach(function(integer) {
it('should serialize integer ' + integer, function(done) {
db.run("INSERT INTO int_table VALUES(?)", integer);
db.run("INSERT INTO int_table VALUES(?)", integer, function (err) {
if (err) throw err;
db.get("SELECT int AS integer FROM int_table", function(err, row) {
if (err) throw err;
assert.equal(row.integer, integer);
......@@ -78,4 +85,5 @@ describe('data types', function() {
});
});
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment