forked from sql-js/sql.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_big_int.js
35 lines (29 loc) · 931 Bytes
/
test_big_int.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
exports.test = function(sql, assert){
// Create a database
var db = new sql.Database();
// Create table, insert data
sqlstr = "CREATE TABLE IF NOT EXISTS Test_BigInt (someNumber BIGINT NOT NULL);" +
"INSERT INTO Test_BigInt (someNumber) VALUES (1628675501000);";
db.exec(sqlstr);
var config = {useBigInt: true};
var stmt = db.prepare("SELECT * FROM Test_BigInt;");
stmt.step();
assert.strictEqual(typeof stmt.get()[0], 'number', "Reading number value");
assert.strictEqual(typeof stmt.get(null, config)[0], 'bigint', "Reading bigint value");
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 big int': function(assert){
exports.test(sql, assert);
}
});
})
.catch((e)=>{
console.error(e);
assert.fail(e);
});
}