registry: fix non-unique default dataSources
Fix the problem where `registry.defaultDataSources` has two instances: - `require('loopback').defaultDataSources` used by `loopback.autoAttach()` - `require('./registry').defaultDataSources` used by `app.dataSource`. I am intentionally leaving out unit-tests as the whole `autoAttach` feature is going to be deleted before 2.0 is released.
This commit is contained in:
parent
56aab8dbdd
commit
09cc57c061
|
@ -13,6 +13,7 @@ var DataSource = require('loopback-datasource-juggler').DataSource;
|
|||
|
||||
var registry = module.exports;
|
||||
|
||||
registry.defaultDataSources = {};
|
||||
|
||||
/**
|
||||
* Create a named vanilla JavaScript class constructor with an attached
|
||||
|
@ -264,8 +265,7 @@ registry.memory = function (name) {
|
|||
*/
|
||||
|
||||
registry.setDefaultDataSourceForType = function(type, dataSource) {
|
||||
var defaultDataSources = this.defaultDataSources ||
|
||||
(this.defaultDataSources = {});
|
||||
var defaultDataSources = this.defaultDataSources;
|
||||
|
||||
if(!(dataSource instanceof DataSource)) {
|
||||
dataSource = this.createDataSource(dataSource);
|
||||
|
|
Loading…
Reference in New Issue