diff --git a/test/test_issue325.js b/test/test_issue325.js index 6a606a8c..5e4827ab 100644 --- a/test/test_issue325.js +++ b/test/test_issue325.js @@ -4,45 +4,22 @@ exports.test = function(sql, assert){ // Create a database var db = new sql.Database(); var result; - var stmt; var value; // inline result value test - result = db.exec("SELECT 1.7976931348623157e+308 AS myResult"); - assert.strictEqual(result.length, 1, 'correct inline result length'); - assert.deepEqual(result[0].columns, ['myResult'], 'correct inline result column name'); - assert.strictEqual(result[0].values.length, 1, 'correct inline result values length'); - assert.strictEqual(result[0].values[0].length, 1, 'inline result values[0] length'); - assert.strictEqual(typeof result[0].values[0][0], 'number', 'correct inline result value is a number'); - assert.ok(result[0].values[0][0] > 1.7976931348623e+308, 'inline result value is not too small'); - assert.ok(result[0].values[0][0] < 1.797693134862316e+308, 'inline result value is not too large'); - assert.notEqual(result[0].values[0][0], Infinity, 'inline result value is not Infinity'); - value = String(result[0].values[0][0]); - assert.strictEqual(value, "1.7976931348623157e+308"); + result = db.exec("SELECT 1.7976931348623157e+308 AS value"); + value = result[0].values[0][0]; + assert.strictEqual(value, 1.7976931348623157e+308); // bind result value test - stmt = db.prepare("SELECT ? AS myResult"); - result = stmt.getAsObject([1.7976931348623157e+308]); - assert.ok(result.myResult, 'bind result value is valid and defined'); - assert.strictEqual(typeof result.myResult, 'number', 'bind result value is a number'); - assert.ok(result.myResult > 1.7976931348623e+308, 'bind result value is not too small'); - assert.ok(result.myResult < 1.797693134862316e+308, 'bind result value is not too large'); - assert.notEqual(result.myResult, Infinity, 'bind result value is not Infinity'); - value = String(result.myResult); - assert.strictEqual(value, "1.7976931348623157e+308"); + result = db.exec("SELECT ? AS value", [1.7976931348623157e+308]); + value = result[0].values[0][0]; + assert.strictEqual(value, 1.7976931348623157e+308); // CAST value test - result = db.exec("SELECT CAST('1.7976931348623157e+308' AS REAL) AS myResult"); - assert.strictEqual(result.length, 1, 'correct inline result length'); - assert.deepEqual(result[0].columns, ['myResult'], 'correct inline result column name'); - assert.strictEqual(result[0].values.length, 1, 'correct inline result values length'); - assert.strictEqual(result[0].values[0].length, 1, 'inline result values[0] length'); - assert.strictEqual(typeof result[0].values[0][0], 'number', 'correct inline result value is a number'); - assert.ok(result[0].values[0][0] > 1.7976931348623e+308, 'inline result value is not too small'); - assert.ok(result[0].values[0][0] < 1.797693134862316e+308, 'inline result value is not too large'); - assert.notEqual(result[0].values[0][0], Infinity, 'inline result value is not Infinity'); - value = String(result[0].values[0][0]); - assert.strictEqual(value, "1.7976931348623157e+308"); + result = db.exec("SELECT CAST('1.7976931348623157e+308' AS REAL) AS value"); + value = result[0].values[0][0]; + assert.strictEqual(value, 1.7976931348623157e+308); // Close the database and all associated statements db.close();