Merge pull request #60 from serkanserttop/fix-inherit-schema-from-datasource

Inherit Schema From DataSource if not defined
This commit is contained in:
Raymond Feng 2015-01-14 14:48:22 -08:00
commit de299aed9f
1 changed files with 19 additions and 0 deletions

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;
}
}