Merge branch 'release/1.5.1' into production

This commit is contained in:
Raymond Feng 2015-01-15 14:33:11 -08:00
commit 7cb6efe454
4 changed files with 57 additions and 8 deletions

View File

@ -1,3 +1,21 @@
2015-01-15, Version 1.5.1
=========================
* Fix the loop of models (Raymond Feng)
* Set ok default to false (Geoffroy Lesage)
* Fixed missing 'ok' (Geoffroy Lesage)
* Changed default type mapping (Geoffroy Lesage)
* Fixed isActual syntax to accept optional model arg (Geoffroy Lesage)
* Fixed isActual implemenation (Geoffroy Lesage)
* Inherit Schema From DataSource if not defined (Serkan Serttop)
2015-01-09, Version 1.5.0
=========================

View File

@ -177,6 +177,9 @@ function mixinDiscovery(MySQL) {
MySQL.prototype.discoverModelProperties = function (table, options, cb) {
var args = getArgs(table, options, cb);
var owner = args.owner;
if(!owner){
owner = inheritOwnerViaDataSource.call(this);
}
table = args.table;
options = args.options;
cb = args.cb;
@ -228,6 +231,9 @@ function mixinDiscovery(MySQL) {
MySQL.prototype.discoverPrimaryKeys = function (table, options, cb) {
var args = getArgs(table, options, cb);
var owner = args.owner;
if(!owner){
owner = inheritOwnerViaDataSource.call(this);
}
table = args.table;
options = args.options;
cb = args.cb;
@ -269,6 +275,9 @@ function mixinDiscovery(MySQL) {
MySQL.prototype.discoverForeignKeys = function (table, options, cb) {
var args = getArgs(table, options, cb);
var owner = args.owner;
if(!owner){
owner = inheritOwnerViaDataSource.call(this);
}
table = args.table;
options = args.options;
cb = args.cb;
@ -312,6 +321,9 @@ function mixinDiscovery(MySQL) {
MySQL.prototype.discoverExportedForeignKeys = function (table, options, cb) {
var args = getArgs(table, options, cb);
var owner = args.owner;
if(!owner){
owner = inheritOwnerViaDataSource.call(this);
}
table = args.table;
options = args.options;
cb = args.cb;
@ -366,4 +378,11 @@ function mixinDiscovery(MySQL) {
return 'String';
}
}
function inheritOwnerViaDataSource(){
if(this.dataSource && this.dataSource.settings && this.dataSource.settings.database){
return this.dataSource.settings.database;
}
return undefined;
}
}

View File

@ -690,10 +690,22 @@ MySQL.prototype.createTable = function (model, cb) {
* @param {String[]} [models] A model name or an array of model names. If not present, apply to all models
* @param {Function} [cb] The callback function
*/
MySQL.prototype.isActual = function(cb) {
MySQL.prototype.isActual = function(models, cb) {
var self = this;
var ok = false;
async.each(Object.keys(this._models), function(model, done) {
if ((!cb) && ('function' === typeof models)) {
cb = models;
models = undefined;
}
// First argument is a model name
if ('string' === typeof models) {
models = [models];
}
models = models || Object.keys(this._models);
async.each(models, function(model, done) {
var table = self.tableEscaped(model);
self.query('SHOW FIELDS FROM ' + table, function(err, fields) {
self.query('SHOW INDEXES FROM ' + table, function(err, indexes) {
@ -1025,10 +1037,6 @@ function datatype(p) {
var dt = '';
switch (p.type.name) {
default:
case 'String':
dt = columnType(p, 'VARCHAR');
dt = stringOptionsByType(p, dt);
break;
case 'JSON':
case 'Object':
case 'Any':
@ -1036,6 +1044,10 @@ function datatype(p) {
dt = columnType(p, 'TEXT');
dt = stringOptionsByType(p, dt);
break;
case 'String':
dt = columnType(p, 'VARCHAR');
dt = stringOptionsByType(p, dt);
break;
case 'Number':
dt = columnType(p, 'INT');
dt = numericOptionsByType(p, dt);

View File

@ -1,6 +1,6 @@
{
"name": "loopback-connector-mysql",
"version": "1.5.0",
"version": "1.5.1",
"description": "MySQL connector for loopback-datasource-juggler",
"main": "index.js",
"scripts": {
@ -27,6 +27,6 @@
"url": "https://github.com/strongloop/loopback-connector-mysql/blob/master/LICENSE"
},
"optionalDependencies": {
"sl-blip": "http://blip.strongloop.com/loopback-connector-mysql@1.5.0"
"sl-blip": "http://blip.strongloop.com/loopback-connector-mysql@1.5.1"
}
}