diff --git a/+dj/conn.m b/+dj/conn.m index a78adda0..45a67d46 100644 --- a/+dj/conn.m +++ b/+dj/conn.m @@ -51,13 +51,6 @@ end end else - % optional environment variables specifying the connection. - env = struct(... - 'host', 'DJ_HOST', ... - 'user', 'DJ_USER', ... - 'pass', 'DJ_PASS', ... - 'init', 'DJ_INIT'); - % get host address if isempty(host) host = input('Enter datajoint host address> ','s'); diff --git a/.github/workflows/development.yaml b/.github/workflows/development.yaml index 0620a4e9..d9fe2088 100644 --- a/.github/workflows/development.yaml +++ b/.github/workflows/development.yaml @@ -36,4 +36,4 @@ jobs: DOCKER_CLIENT_TIMEOUT: "120" COMPOSE_HTTP_TIMEOUT: "120" run: | - docker-compose -f LNX-docker-compose.yml up --build --exit-code-from app + docker-compose -f LNX-docker-compose.yaml up --build --exit-code-from app diff --git a/.gitignore b/.gitignore index d91a9e75..63208af2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ mym/ *.env notebook *getSchema.m -docker-compose.yml +docker-compose.yaml .vscode matlab.prf win.* diff --git a/LNX-docker-compose.yml b/LNX-docker-compose.yaml similarity index 81% rename from LNX-docker-compose.yml rename to LNX-docker-compose.yaml index 6c35c922..4e63e505 100644 --- a/LNX-docker-compose.yml +++ b/LNX-docker-compose.yaml @@ -1,4 +1,4 @@ -# docker-compose -f LNX-docker-compose.yml --env-file LNX.env up --build --exit-code-from app +# docker-compose -f LNX-docker-compose.yaml --env-file LNX.env up --build --exit-code-from app version: '2.2' x-net: &net networks: @@ -79,11 +79,11 @@ services: try\ websave([tempdir 'GHToolbox.mltbx'],\ ['https://github.com/datajoint/GHToolbox' \ - '/releases/download/' subsref(webread(['https://api.github.com/repos' \ + '/releases/download/' subsref(webread(['https://api.github.com/repos' \ '/datajoint/GHToolbox' \ '/releases/latest']),\ - substruct('.', 'tag_name')) \ - '/GHToolbox.mltbx']);\ + substruct('.', 'tag_name')) \ + '/GHToolbox.mltbx']);\ matlab.addons.toolbox.installToolbox([tempdir 'GHToolbox.mltbx']);\ fid = fopen('README.md', 'r');\ docs = fread(fid, '*char')';\ @@ -92,18 +92,19 @@ services: 'Raphael Guzman',\ 'raphael.h.guzman@gmail.com',\ ['Scientific workflow management framework built on top of a ' \ - 'relational database.'],\ + 'relational database.'],\ docs,\ - {'.vscode', '.git', '*.env', '.gitignore', '*.yml', 'tests', 'mym'\ - 'docs-parts', '*.txt', '*.prf', '*.md'},\ + {'.vscode', '.git*', '*.env', '*.yaml', 'tests', 'mym', 'docs-parts',\ + '*.txt', '*.prf', '*.md', 'notebook'},\ @() strjoin(arrayfun(@(x) num2str(x),\ - cell2mat(struct2cell(dj.version)),\ - 'uni', false),\ - '.'),\ + cell2mat(struct2cell(dj.version)),\ + 'uni', false),\ + '.'),\ {'+dj', 'erd.m'});\ matlab.addons.toolbox.installToolbox('DataJoint.mltbx');\ cd(getenv('ORIG_DIR'));\ addpath('tests');\ + dir(fileparts(which('erd')));\ res=run(Main);\ disp(res);\ if all([res.Passed]) exit, else exit(1), end;\ diff --git a/README.md b/README.md index 0dad0806..0bae0152 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ MATLAB_UID=1000 MATLAB_GID=1000 MYSQL_TAG=5.7 ``` -* `cp local-docker-compose.yml docker-compose.yml` +* `cp local-docker-compose.yaml docker-compose.yaml` * `docker-compose up` (Note configured `JUPYTER_PASSWORD`) * Select a means of running MATLAB e.g. Jupyter Notebook, GUI, or Terminal (see bottom) * Add `tests` directory to path e.g. in MATLAB, `addpath('tests')` diff --git a/local-docker-compose.yml b/local-docker-compose.yaml similarity index 93% rename from local-docker-compose.yml rename to local-docker-compose.yaml index 28e82504..e40e0d84 100644 --- a/local-docker-compose.yml +++ b/local-docker-compose.yaml @@ -1,4 +1,4 @@ -# docker-compose -f local-docker-compose.yml --env-file LNX.env up --build +# docker-compose -f local-docker-compose.yaml --env-file LNX.env up --build version: '2.4' x-net: &net networks: @@ -105,8 +105,8 @@ services: ['Scientific workflow management framework built on top of a ' \ 'relational database.'],\ docs,\ - {'.vscode', '.git', '*.env', '.gitignore', '*.yml', 'tests', 'mym'\ - 'docs-parts', '*.txt', '*.prf', '*.md'},\ + {'.vscode', '.git*', '*.env', '*.yaml', 'tests', 'mym', 'docs-parts',\ + '*.txt', '*.prf', '*.md', 'notebook'},\ @() strjoin(arrayfun(@(x) num2str(x),\ cell2mat(struct2cell(dj.version)),\ 'uni', false),\ @@ -116,6 +116,7 @@ services: addpath('tests');\ savepath;\ cd(tempdir);\ + dir(fileparts(which('erd')));\ disp(dj.version);\ " cd "$${ORIG_DIR}" diff --git a/tests/TestConnection.m b/tests/TestConnection.m index cd42ec3b..f36aaf73 100644 --- a/tests/TestConnection.m +++ b/tests/TestConnection.m @@ -39,5 +39,39 @@ function TestConnection_testPort(testCase) testCase.CONN_INFO.password,'',true), ... 'MySQL:Error'); end + function TestConnection_testTransactionRollback(testCase) + st = dbstack; + disp(['---------------' st(1).name '---------------']); + package = 'University'; + + c1 = dj.conn(... + testCase.CONN_INFO.host,... + testCase.CONN_INFO.user,... + testCase.CONN_INFO.password,'',true); + dj.createSchema(package,[testCase.test_root '/test_schemas'], ... + [testCase.PREFIX '_university']); + schema = University.getSchema; + tmp = { + 20 'Henry' 'Jupyter' '2020-11-25 12:34:56' + 21 'Lacy' 'Mars' '2017-11-25 12:34:56' + }; + + insert(University.Student, tmp(1, :)); + + schema.conn.startTransaction + try + insert(University.Student, tmp(2, :)); + assert(false, 'Customer:Error', 'Message') + catch ME + schema.conn.cancelTransaction + if ~strcmp(ME.identifier,'Customer:Error') + rethrow(ME); + end + end + + q = University.Student & 'student_id in (20,21)'; + testCase.verifyEqual(q.count, 1); + testCase.verifyEqual(q.fetch1('student_id'), 20); + end end end \ No newline at end of file diff --git a/tests/TestTls.m b/tests/TestTls.m index a10319b8..4ed33df8 100644 --- a/tests/TestTls.m +++ b/tests/TestTls.m @@ -47,11 +47,6 @@ function TestTls_testRejectException(testCase) 'djssl', ... '',true,false); testCase.verifyTrue(false); - % catch - % e = lasterror; - % testCase.verifyEqual(e.identifier, 'MySQL:Error'); - % testCase.verifyTrue(contains(e.message,... - % {'requires secure connection','Access denied'})); %MySQL8,MySQL5 catch ME testCase.verifyEqual(ME.identifier, 'MySQL:Error'); testCase.verifyTrue(contains(ME.message,'requires secure connection') || ...