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:
Miroslav Bajtoš 2014-06-09 16:15:56 +02:00
parent 362cceb70a
commit f05291ca93
1 changed files with 2 additions and 2 deletions

View File

@ -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);