Skip to content

Commit

Permalink
Fix issue with large numbers (#381)
Browse files Browse the repository at this point in the history
* - remove `-DLONGDOUBLE_TYPE=double` from `Makefile`
- update test to include CAST(1.7976931348623157e+308 AS REAL)
- add test-case to verify infinity upper-bound
- Co-authored-by: Christopher J. Brody <chris.brody at gmail.com>

* Update test/test_issue325.js

Co-authored-by: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
  • Loading branch information
kaizhu256 and lovasoa authored Apr 4, 2020
1 parent da3ff68 commit 30a554c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ EMCC=emcc

CFLAGS = \
-O2 \
-DLONGDOUBLE_TYPE=double \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_DISABLE_LFS \
-DSQLITE_ENABLE_FTS3 \
Expand Down
39 changes: 39 additions & 0 deletions test/test_issue325.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

exports.test = function(sql, assert){
"use strict";
// Create a database
var db = new sql.Database();

// binding a large number
assert.strictEqual(
db.exec("SELECT ?", [1.7976931348623157e+308])[0].values[0][0],
1.7976931348623157e+308,
"binding 1.7976931348623159e+308 as a parameter"
);

// inline result value test
assert.strictEqual(
db.exec("SELECT 1.7976931348623157e+308")[0].values[0][0],
1.7976931348623157e+308,
"SELECT 1.7976931348623157e+308 is 1.7976931348623157e+308"
);

// Close the database and all associated statements
db.close();
};

if (module == require.main) {
const target_file = process.argv[2];
const sql_loader = require('./load_sql_lib');
sql_loader(target_file).then((sql)=>{
require('test').run({
'test issue325': function(assert){
exports.test(sql, assert);
}
});
})
.catch((e)=>{
console.error(e);
assert.fail(e);
});
}

0 comments on commit 30a554c

Please sign in to comment.