From 09cc57c0613617f43e93c657a96bca589ef00ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 9 Jun 2014 16:15:56 +0200 Subject: [PATCH] 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. --- lib/registry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/registry.js b/lib/registry.js index 311d0b08..0945af7d 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -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);