Remove troublesome/unstable sqlite3 adapter. Dblite supports sqlite3, and actually installs reliably
This commit is contained in:
parent
16f86e9a92
commit
512a31ba95
@ -10,7 +10,6 @@ A node query builder for various SQL databases, based on CodeIgniter's query bui
|
||||
* mysql2
|
||||
* pg
|
||||
* dblite
|
||||
* sqlite3
|
||||
* node-firebird
|
||||
|
||||
### Installation
|
||||
|
@ -103,7 +103,6 @@
|
||||
<li>mysql2</li>
|
||||
<li>pg</li>
|
||||
<li>dblite</li>
|
||||
<li>sqlite3</li>
|
||||
<li>node-firebird</li>
|
||||
</ul>
|
||||
<h3>Installation</h3><pre class="prettyprint source"><code>npm install ci-node-query</code></pre><h3>Basic use</h3><pre class="prettyprint source"><code>var nodeQuery = require('ci-node-query');
|
||||
|
@ -1,29 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var adapter = require('../adapter'),
|
||||
getArgs = require('getargs');
|
||||
|
||||
/** @module adapters/dblite */
|
||||
var Sqlite3 = function(instance) {
|
||||
|
||||
// That 'new' keyword is annoying
|
||||
if ( ! (this instanceof Sqlite3)) return new Sqlite3(instance);
|
||||
|
||||
/**
|
||||
* Run the sql query as a prepared statement
|
||||
*
|
||||
* @param {String} sql - The sql with placeholders
|
||||
* @param {Array} params - The values to insert into the query
|
||||
* @param {Function} callback - Callback to run when a response is recieved
|
||||
* @return void
|
||||
*/
|
||||
adapter.execute = function(/*sql, params, callback*/) {
|
||||
var args = getArgs('sql:string, [params]:array, callback:function', arguments);
|
||||
|
||||
instance.all(args.sql, args.params, args.callback);
|
||||
};
|
||||
|
||||
return adapter;
|
||||
}
|
||||
|
||||
module.exports = Sqlite3;
|
@ -25,7 +25,6 @@
|
||||
"postgres",
|
||||
"sqlite",
|
||||
"dblite",
|
||||
"sqlite3",
|
||||
"firebird",
|
||||
"node-firebird"
|
||||
],
|
||||
@ -46,7 +45,6 @@
|
||||
"optionalDependencies": {
|
||||
"dblite": "^0.6.1",
|
||||
"node-firebird": "^0.2.4",
|
||||
"sqlite3": "^3.0.2",
|
||||
"pg": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -67,7 +65,6 @@
|
||||
"mysql2",
|
||||
"node-firebird",
|
||||
"pg",
|
||||
"sqlite3"
|
||||
],
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
@ -1,94 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// Load the test base
|
||||
delete require.cache[require.resolve('../query-builder-base')];
|
||||
var testBase = require('../query-builder-base');
|
||||
var tests = testBase.tests;
|
||||
|
||||
// Load the test config file
|
||||
var adapterName = 'sqlite3';
|
||||
var sqlite = null;
|
||||
var connection = null;
|
||||
|
||||
// Set up the connection
|
||||
try {
|
||||
sqlite = require(adapterName).verbose();
|
||||
connection = new sqlite.Database(':memory:');
|
||||
} catch (e) {
|
||||
// Export an empty testsuite if module not loaded
|
||||
console.log(e);
|
||||
console.log("Database adapter sqlite3 not found");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (connection)
|
||||
{
|
||||
// Set up the query builder object
|
||||
var nodeQuery = require('../../lib/node-query');
|
||||
var qb = nodeQuery.init('sqlite', connection, adapterName);
|
||||
|
||||
// Set up the sqlite database
|
||||
var sql = 'CREATE TABLE IF NOT EXISTS "create_test" ("id" INTEGER PRIMARY KEY, "key" TEXT, "val" TEXT);';
|
||||
var sql2 = 'CREATE TABLE IF NOT EXISTS "create_join" ("id" INTEGER PRIMARY KEY, "key" TEXT, "val" TEXT);';
|
||||
connection.serialize(function() {
|
||||
connection.run(sql);
|
||||
connection.run(sql2);
|
||||
});
|
||||
|
||||
// Set up the test base
|
||||
testBase._setUp(qb, function(test, err, result) {
|
||||
if (err != null) {
|
||||
test.done();
|
||||
throw new Error(err);
|
||||
}
|
||||
|
||||
// Insert/Update/Delete queries return undefined
|
||||
if (result === undefined) {
|
||||
result = {};
|
||||
}
|
||||
|
||||
test.ok(result, 'sqlite3: Valid result for generated query');
|
||||
test.done();
|
||||
});
|
||||
|
||||
tests['Select tests']['Select with function and argument in WHERE clause'] = function(test) {
|
||||
test.expect(1);
|
||||
qb.select('id')
|
||||
.from('create_test')
|
||||
.where('id', 'ABS(-88)')
|
||||
.get(function(err, rows) {
|
||||
if (err != null) {
|
||||
test.done();
|
||||
throw new Error(err);
|
||||
}
|
||||
|
||||
test.ok(rows, 'sqlite3: Valid result for generated query');
|
||||
test.done();
|
||||
});
|
||||
};
|
||||
|
||||
tests['nodeQuery.getQuery = nodeQuery.init'] = function(test) {
|
||||
test.expect(1);
|
||||
test.deepEqual(qb, nodeQuery.getQuery(), "getQuery returns same object");
|
||||
test.done();
|
||||
};
|
||||
|
||||
tests["sqlite3 adapter with query builder"] = function(test) {
|
||||
test.expect(1);
|
||||
test.ok(testBase.qb);
|
||||
|
||||
// Close the db connection
|
||||
connection.close();
|
||||
test.done();
|
||||
};
|
||||
|
||||
// Export the final test object
|
||||
module.exports = tests;
|
||||
}
|
||||
else
|
||||
{
|
||||
module.exports = {};
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user