Fix missing connector alias
This commit is contained in:
parent
b78050410d
commit
bf83a76eae
|
@ -1,7 +1,6 @@
|
|||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var ModelBuilder = require('./model-builder.js').ModelBuilder;
|
||||
var jutil = require('./jutil');
|
||||
var ModelBaseClass = require('./model.js');
|
||||
|
@ -62,7 +61,7 @@ function DataSource(name, settings) {
|
|||
var connector = this.connector();
|
||||
|
||||
// DataAccessObject - connector defined or supply the default
|
||||
this.DataAccessObject = connector.DataAccessObject || this.constructor.DataAccessObject;
|
||||
this.DataAccessObject = (connector && connector.DataAccessObject) ? connector.DataAccessObject : this.constructor.DataAccessObject;
|
||||
this.DataAccessObject.call(this, arguments);
|
||||
|
||||
// operation metadata
|
||||
|
@ -116,6 +115,19 @@ for (var m in ModelBuilder) {
|
|||
|
||||
DataSource.prototype.setup = function(name, settings) {
|
||||
var schema = this;
|
||||
var adapter;
|
||||
|
||||
// support single settings object
|
||||
if(typeof name === 'object') {
|
||||
settings = name;
|
||||
name = undefined;
|
||||
}
|
||||
if(settings) {
|
||||
adapter = settings.connector || settings.adapter;
|
||||
}
|
||||
if(settings.initialize) {
|
||||
adapter = settings;
|
||||
}
|
||||
|
||||
// just save everything we get
|
||||
this.name = name;
|
||||
|
@ -125,11 +137,10 @@ DataSource.prototype.setup = function(name, settings) {
|
|||
this.connected = false;
|
||||
this.connecting = false;
|
||||
|
||||
if (name) {
|
||||
if (name && !adapter) {
|
||||
// and initialize schema using adapter
|
||||
// this is only one initialization entry point of adapter
|
||||
// this module should define `adapter` member of `this` (schema)
|
||||
var adapter;
|
||||
if (typeof name === 'object') {
|
||||
adapter = name;
|
||||
this.name = adapter.name;
|
||||
|
@ -201,6 +212,15 @@ DataSource.prototype.setup = function(name, settings) {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the connector.
|
||||
*/
|
||||
|
||||
DataSource.prototype.connector = function () {
|
||||
// alias for adapter compatibility
|
||||
return this.adapter;
|
||||
};
|
||||
|
||||
/**
|
||||
* Define class
|
||||
*
|
||||
|
@ -260,6 +280,9 @@ DataSource.prototype.define = function defineClass(className, properties, settin
|
|||
|
||||
};
|
||||
|
||||
// alias createModel
|
||||
DataSource.prototype.createModel = DataSource.prototype.define;
|
||||
|
||||
/**
|
||||
* Mixin DataAccessObject methods.
|
||||
*/
|
||||
|
@ -773,7 +796,6 @@ DataSource.prototype.discoverSchemasSync = function (owner, tableOrView, options
|
|||
});
|
||||
|
||||
// Add current tableOrView to the visited tables
|
||||
options = options || {};
|
||||
options.visited = options.visited || {};
|
||||
var schemaKey = columns[0].owner + '.' + tableOrView;
|
||||
if (!options.visited.hasOwnProperty(schemaKey)) {
|
||||
|
|
Loading…
Reference in New Issue