Comparing version 0.1.2 to 0.2.0
{ | ||
"name": "sql.js", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "SQLite library with support for opening and writing databases, prepared statements, and more. This SQLite library is in pure javascript (compiled with emscripten).", | ||
@@ -5,0 +5,0 @@ "keywords": ["SQL", "SQLite", "database", "emscripten"], |
# SQLite compiled to javascript | ||
[](http://travis-ci.org/lovasoa/sql.js) | ||
@@ -25,4 +26,11 @@ This is my fork of sql.js, by kripken. Try it online here: http://lovasoa.github.io/sql.js/GUI/ | ||
sqlstr += "INSERT INTO hello VALUES (1, 'world');" | ||
db.exec(sqlstr); | ||
db.run(sqlstr); // Run the query without returning anything | ||
var res = db.exec("SELECT * FROM hello"); | ||
/* | ||
[ | ||
{columns:['a','b'], values:[[0,'hello'],[1,'world']]} | ||
] | ||
*/ | ||
// Prepare an sql statement | ||
@@ -29,0 +37,0 @@ var stmt = db.prepare("SELECT * FROM hello WHERE a=:aval AND b=:bval"); |
exports.test = function(sql, assert) { | ||
assert.notEqual(sql.Database, undefined, "Should export a Database object"); | ||
console.log("Testing database creation..."); | ||
// Create a database | ||
@@ -11,6 +10,7 @@ var db = new sql.Database(); | ||
sqlstr = "CREATE TABLE test (a, b, c, d, e);"; | ||
sqlstr += "INSERT INTO test VALUES (NULL, 42, 4.2, 'fourty two', x'42');"; | ||
var res = db.exec(sqlstr); | ||
assert.deepEqual(res, [], "Table creation should not return anything"); | ||
assert.deepEqual(res, [], "Creating a table should not return anything"); | ||
db.run("INSERT INTO test VALUES (NULL, 42, 4.2, 'fourty two', x'42');"); | ||
//Retrieving values | ||
@@ -22,3 +22,3 @@ sqlstr = "SELECT * FROM test;"; | ||
values : [ | ||
['','42','4.2','fourty two', String.fromCharCode(0x42)] | ||
[null,42,4.2,'fourty two', new Uint8Array([0x42])] | ||
] | ||
@@ -28,2 +28,3 @@ }]; | ||
// Export the database to an Uint8Array containing the SQLite database file | ||
@@ -30,0 +31,0 @@ var binaryArray = db.export(); |
@@ -16,3 +16,3 @@ exports.test = function(SQL, assert) { | ||
assert.deepEqual(res, | ||
[{"columns":["id","content"],"values":[["0","hello"]]}], | ||
[{"columns":["id","content"],"values":[[0,"hello"]]}], | ||
"One should be able to read the contents of an SQLite database file read from disk"); | ||
@@ -19,0 +19,0 @@ db.close(); |
@@ -25,3 +25,3 @@ exports.test = function(sql, assert){ | ||
assert.deepEqual(result, | ||
[{columns:['letter', 'code'], values:[['a','1'],['b','2.2'],['c','']]}], | ||
[{columns:['letter', 'code'], values:[['a',1],['b',2.2],['c',null]]}], | ||
"Statement.run() should have added data to the database"); | ||
@@ -28,0 +28,0 @@ |
Sorry, the diff of this file is too big to display
86
1592508
6376