diff --git a/CHANGES.md b/CHANGES.md index 0ea866a..c7ad001 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 ========================= diff --git a/lib/discovery.js b/lib/discovery.js index 2ff4696..46429b0 100644 --- a/lib/discovery.js +++ b/lib/discovery.js @@ -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; + } } diff --git a/lib/mysql.js b/lib/mysql.js index 0864a2e..38d76aa 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -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); diff --git a/package.json b/package.json index 68688cc..5423c8c 100644 --- a/package.json +++ b/package.json @@ -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" } }