Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions +dj/conn.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@


if isa(CONN, 'dj.Connection') && ~reset
assert(nargin==0, ...
'connection already instantiated. To reconnect, clear functions')
if nargin>0
warning(sprintf(['Connection already instantiated.\n' ...
'Will use existing connection to "' CONN.host '".\n' ...
'To reconnect, set reset to true']));
end
else
% invoke setupDJ
% optional environment variables specifying the connection.
Expand Down
8 changes: 8 additions & 0 deletions +tests/TestConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,13 @@ function testConnection(testCase)
testCase.CONN_INFO.user,...
testCase.CONN_INFO.password,'',true).isConnected);
end
function testConnectionExists(testCase)
% testConnectionExists tests that will not fail if connection open.
% Fix https://github.com/datajoint/datajoint-matlab/issues/160
st = dbstack;
disp(['---------------' st(1).name '---------------']);
dj.conn(testCase.CONN_INFO.host, '', '', '', '', true)
dj.conn(testCase.CONN_INFO.host, '', '', '', '', true)
end
end
end