Merge pull request #126 from strongloop/update-deps
Drop support for Node.js 4.x + update dependencies
This commit is contained in:
commit
45cbee7602
|
@ -1,5 +1,6 @@
|
||||||
sudo: false
|
sudo: false
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "4"
|
|
||||||
- "6"
|
- "6"
|
||||||
|
- "8"
|
||||||
|
- "10"
|
||||||
|
|
40
lib/sql.js
40
lib/sql.js
|
@ -167,7 +167,7 @@ SQLConnector.prototype.addPropertyToActual = function(model, propName) {
|
||||||
var sqlCommand = self.columnEscaped(model, propName) +
|
var sqlCommand = self.columnEscaped(model, propName) +
|
||||||
' ' + self.columnDataType(model, propName) +
|
' ' + self.columnDataType(model, propName) +
|
||||||
(self.isNullable(self.getPropertyDefinition(model, propName)) ?
|
(self.isNullable(self.getPropertyDefinition(model, propName)) ?
|
||||||
'' : ' NOT NULL');
|
'' : ' NOT NULL');
|
||||||
return sqlCommand;
|
return sqlCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -631,17 +631,17 @@ SQLConnector.prototype.execute = function(sql, params, options, callback) {
|
||||||
};
|
};
|
||||||
this.notifyObserversAround('execute', context, function(context, done) {
|
this.notifyObserversAround('execute', context, function(context, done) {
|
||||||
self.executeSQL(context.req.sql, context.req.params, context.options,
|
self.executeSQL(context.req.sql, context.req.params, context.options,
|
||||||
function(err, info) {
|
function(err, info) {
|
||||||
if (err) {
|
if (err) {
|
||||||
debug('Error: %j %j %j', err, context.req.sql, context.req.params);
|
debug('Error: %j %j %j', err, context.req.sql, context.req.params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!err && info != null) {
|
if (!err && info != null) {
|
||||||
context.res = info;
|
context.res = info;
|
||||||
}
|
}
|
||||||
// Don't pass more than one args as it will confuse async.waterfall
|
// Don't pass more than one args as it will confuse async.waterfall
|
||||||
done(err, info);
|
done(err, info);
|
||||||
});
|
});
|
||||||
}, callback);
|
}, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ SQLConnector.prototype.updateAttributes = function(model, id, data, options, cb)
|
||||||
|
|
||||||
function errorIdNotFoundForUpdate(idValue) {
|
function errorIdNotFoundForUpdate(idValue) {
|
||||||
var msg = g.f(
|
var msg = g.f(
|
||||||
'Could not update attributes. {{Object}} with {{id}} %s does not exist!', idValue);
|
'Could not update attributes. {{Object}} with {{id}} %s does not exist!', idValue);
|
||||||
var error = new Error(msg);
|
var error = new Error(msg);
|
||||||
error.statusCode = error.status = 404;
|
error.statusCode = error.status = 404;
|
||||||
return error;
|
return error;
|
||||||
|
@ -1784,8 +1784,8 @@ SQLConnector.prototype.discoverDatabaseSchemas = function(options, cb) {
|
||||||
* @param options {all: for all owners, owner: for a given owner}
|
* @param options {all: for all owners, owner: for a given owner}
|
||||||
* @returns {string} The sql statement
|
* @returns {string} The sql statement
|
||||||
*/
|
*/
|
||||||
// Due to the different implementation structure of information_schema across
|
// Due to the different implementation structure of information_schema across
|
||||||
// connectors, each connector will have to generate its own query
|
// connectors, each connector will have to generate its own query
|
||||||
SQLConnector.prototype.buildQueryTables = function(options) {
|
SQLConnector.prototype.buildQueryTables = function(options) {
|
||||||
throw new Error(g.f('{{buildQueryTables}} must be implemented by the connector'));
|
throw new Error(g.f('{{buildQueryTables}} must be implemented by the connector'));
|
||||||
};
|
};
|
||||||
|
@ -1795,8 +1795,8 @@ SQLConnector.prototype.buildQueryTables = function(options) {
|
||||||
* @param options {all: for all owners, owner: for a given owner}
|
* @param options {all: for all owners, owner: for a given owner}
|
||||||
* @returns {string} The sql statement
|
* @returns {string} The sql statement
|
||||||
*/
|
*/
|
||||||
// Due to the different implementation structure of information_schema across
|
// Due to the different implementation structure of information_schema across
|
||||||
// connectors, each connector will have to generate its own query
|
// connectors, each connector will have to generate its own query
|
||||||
SQLConnector.prototype.buildQueryViews = function(options) {
|
SQLConnector.prototype.buildQueryViews = function(options) {
|
||||||
throw new Error(g.f('{{buildQueryViews}} must be implemented by the connector'));
|
throw new Error(g.f('{{buildQueryViews}} must be implemented by the connector'));
|
||||||
};
|
};
|
||||||
|
@ -1946,8 +1946,8 @@ SQLConnector.prototype.discoverPrimaryKeys = function(table, options, cb) {
|
||||||
* @param table
|
* @param table
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
// Due to the different implementation structure of information_schema across
|
// Due to the different implementation structure of information_schema across
|
||||||
// connectors, each connector will have to generate its own query
|
// connectors, each connector will have to generate its own query
|
||||||
SQLConnector.prototype.buildQueryForeignKeys = function(schema, table) {
|
SQLConnector.prototype.buildQueryForeignKeys = function(schema, table) {
|
||||||
throw new Error(g.f('{{buildQueryForeignKeys}} must be implemented by the connector'));
|
throw new Error(g.f('{{buildQueryForeignKeys}} must be implemented by the connector'));
|
||||||
};
|
};
|
||||||
|
@ -1982,8 +1982,8 @@ SQLConnector.prototype.discoverForeignKeys = function(table, options, cb) {
|
||||||
* @param table
|
* @param table
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
// Due to the different implementation structure of information_schema across
|
// Due to the different implementation structure of information_schema across
|
||||||
// connectors, each connector will have to generate its own query
|
// connectors, each connector will have to generate its own query
|
||||||
SQLConnector.prototype.buildQueryExportedForeignKeys = function(schema, table) {
|
SQLConnector.prototype.buildQueryExportedForeignKeys = function(schema, table) {
|
||||||
throw new Error(g.f('{{buildQueryExportedForeignKeys}} must be implemented by' +
|
throw new Error(g.f('{{buildQueryExportedForeignKeys}} must be implemented by' +
|
||||||
'the connector'));
|
'the connector'));
|
||||||
|
|
14
package.json
14
package.json
|
@ -3,7 +3,7 @@
|
||||||
"version": "4.4.0",
|
"version": "4.4.0",
|
||||||
"description": "Building blocks for LoopBack connectors",
|
"description": "Building blocks for LoopBack connectors",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=6"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"StrongLoop",
|
"StrongLoop",
|
||||||
|
@ -25,15 +25,15 @@
|
||||||
"async": "^2.1.5",
|
"async": "^2.1.5",
|
||||||
"bluebird": "^3.4.6",
|
"bluebird": "^3.4.6",
|
||||||
"debug": "^3.1.0",
|
"debug": "^3.1.0",
|
||||||
"msgpack5": "^3.4.1",
|
"msgpack5": "^4.2.0",
|
||||||
"strong-globalize": "^3.1.0",
|
"strong-globalize": "^4.1.1",
|
||||||
"uuid": "^3.0.1"
|
"uuid": "^3.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "~3.5.0",
|
"chai": "^4.1.2",
|
||||||
"eslint": "^3.17.1",
|
"eslint": "^4.19.1",
|
||||||
"eslint-config-loopback": "^8.0.0",
|
"eslint-config-loopback": "^10.0.0",
|
||||||
"loopback-datasource-juggler": "^3.12.0",
|
"loopback-datasource-juggler": "^3.12.0",
|
||||||
"mocha": "^3.2.0"
|
"mocha": "^5.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,42 +41,42 @@ describe('transactions', function() {
|
||||||
isolationLevel: Transaction.READ_COMMITTED,
|
isolationLevel: Transaction.READ_COMMITTED,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
},
|
},
|
||||||
function(err, tx) {
|
function(err, tx) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
expect(typeof tx.id).to.eql('string');
|
expect(typeof tx.id).to.eql('string');
|
||||||
hooks = [];
|
hooks = [];
|
||||||
tx.observe('before commit', function(context, next) {
|
tx.observe('before commit', function(context, next) {
|
||||||
hooks.push('before commit');
|
hooks.push('before commit');
|
||||||
next();
|
next();
|
||||||
});
|
|
||||||
tx.observe('after commit', function(context, next) {
|
|
||||||
hooks.push('after commit');
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
tx.observe('before rollback', function(context, next) {
|
|
||||||
hooks.push('before rollback');
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
tx.observe('after rollback', function(context, next) {
|
|
||||||
hooks.push('after rollback');
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
currentTx = tx;
|
|
||||||
Post.create(post, {transaction: tx, model: 'Post'},
|
|
||||||
function(err, p) {
|
|
||||||
if (err) {
|
|
||||||
done(err);
|
|
||||||
} else {
|
|
||||||
p.reviews.create({
|
|
||||||
author: 'John',
|
|
||||||
content: 'Review for ' + p.title,
|
|
||||||
}, {transaction: tx, model: 'Review'},
|
|
||||||
function(err, c) {
|
|
||||||
done(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
tx.observe('after commit', function(context, next) {
|
||||||
|
hooks.push('after commit');
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
tx.observe('before rollback', function(context, next) {
|
||||||
|
hooks.push('before rollback');
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
tx.observe('after rollback', function(context, next) {
|
||||||
|
hooks.push('after rollback');
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
currentTx = tx;
|
||||||
|
Post.create(post, {transaction: tx, model: 'Post'},
|
||||||
|
function(err, p) {
|
||||||
|
if (err) {
|
||||||
|
done(err);
|
||||||
|
} else {
|
||||||
|
p.reviews.create({
|
||||||
|
author: 'John',
|
||||||
|
content: 'Review for ' + p.title,
|
||||||
|
}, {transaction: tx, model: 'Review'},
|
||||||
|
function(err, c) {
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,24 +173,26 @@ describe('transactions', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('timeout', function() {
|
describe('timeout', function() {
|
||||||
|
const TIMEOUT = 50;
|
||||||
before(function() {
|
before(function() {
|
||||||
// Reset the collection
|
// Reset the collection
|
||||||
db.connector.data = {};
|
db.connector.data = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
var post = {title: 't3', content: 'c3'};
|
var post = {title: 't3', content: 'c3'};
|
||||||
before(createPostInTx(post, 50));
|
beforeEach(createPostInTx(post, TIMEOUT));
|
||||||
|
|
||||||
it('should report timeout', function(done) {
|
it('should report timeout', function(done) {
|
||||||
setTimeout(function() {
|
// wait until the "create post" transaction times out
|
||||||
|
setTimeout(runTheTest, TIMEOUT * 3);
|
||||||
|
|
||||||
|
function runTheTest() {
|
||||||
Post.find({where: {title: 't3'}}, {transaction: currentTx},
|
Post.find({where: {title: 't3'}}, {transaction: currentTx},
|
||||||
function(err, posts) {
|
function(err, posts) {
|
||||||
if (err) return done(err);
|
expect(err).to.match(/transaction.*not active/);
|
||||||
expect(posts.length).to.be.eql(1);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 300);
|
}
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should invoke the timeout hook', function(done) {
|
it('should invoke the timeout hook', function(done) {
|
||||||
|
@ -198,6 +200,10 @@ describe('transactions', function() {
|
||||||
next();
|
next();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If the event is not fired quickly enough, then the test can
|
||||||
|
// quickly fail - no need to wait full two seconds (Mocha's default)
|
||||||
|
this.timeout(TIMEOUT * 3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue