Skip to content

Commit 755ea67

Browse files
Merge pull request #355 from datajoint/stage
Fix fetchn on queries with zero results
2 parents 06b37b7 + 05f077f commit 755ea67

File tree

7 files changed

+35
-7
lines changed

7 files changed

+35
-7
lines changed

+dj/+internal/GeneralRelvar.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ function clip(self)
289289
for iArg=1:length(specs)
290290
% if renamed, use the renamed attribute
291291
name = regexp(specs{iArg}, '(\w+)\s*$', 'tokens');
292-
if isnumeric(s(1).(name{1}{1})) && length(s(1).(name{1}{1})) == 1
292+
sel = cellfun(@(x) strcmp(x, name{1}{1}), {self.header.attributes.name});
293+
if self.tableHeader.attributes(sel).isNumeric
293294
varargout{iArg} = [s.(name{1}{1})]';
294295
else
295296
varargout{iArg} = {s.(name{1}{1})}';

+dj/version.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function varargout = version
22
% report DataJoint version
33

4-
v = struct('major',3,'minor',4,'bugfix',1);
4+
v = struct('major',3,'minor',4,'bugfix',2);
55

66
if nargout
77
varargout{1}=v;

LNX-docker-compose.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# docker-compose -f LNX-docker-compose.yaml --env-file LNX.env up --build --exit-code-from app
1+
# docker-compose -f LNX-docker-compose.yaml --env-file LNX.env up --exit-code-from app --build
22
version: '2.2'
33
x-net: &net
44
networks:
@@ -29,7 +29,7 @@ services:
2929
interval: 1s
3030
fakeservices.datajoint.io:
3131
<<: *net
32-
image: raphaelguzman/nginx:v0.0.11
32+
image: datajoint/nginx:v0.0.15
3333
environment:
3434
- ADD_db_TYPE=DATABASE
3535
- ADD_db_ENDPOINT=db:3306
@@ -120,4 +120,4 @@ services:
120120
- ./tests:/tmp/tests
121121
- .:/src
122122
networks:
123-
main:
123+
main:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ MYSQL_TAG=5.7
6060
| ---------------------------- | ------------------------------------------------------------------------------ |
6161
| Run all tests | `run(Main)` |
6262
| Run one class of tests | `run(TestTls)` |
63-
| Run one specific test | `runtests('TestTls/testInsecureConn')` |
63+
| Run one specific test | `runtests('TestTls/TestTls_testInsecureConn')` |
6464
| Run tests based on test name | `import matlab.unittest.TestSuite;`<br>`import matlab.unittest.selectors.HasName;`<br>`import matlab.unittest.constraints.ContainsSubstring;`<br>`suite = TestSuite.fromClass(?Main, ... `<br><code>&nbsp;&nbsp;&nbsp;&nbsp;</code>`HasName(ContainsSubstring('Conn')));`<br>`run(suite)`|
6565

6666

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.. code-block:: matlab
22
3-
key.scah_idx = fetch1(Scan & key, 'next=max(scan_idx)+1')
3+
key.scan_idx = fetch1(Scan & key, 'max(scan_idx)+1 -> next')
44

docs-parts/intro/Releases_lang1.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
3.4.2 -- March 16, 2021
2+
--------------------------
3+
* Bugfix: Fetchn with zero results throws an error (#353) PR #355
4+
* Bugfix: Syntax error in documentation for next auto_increment value (#352) PR #355
5+
16
3.4.1 -- December 18, 2020
27
--------------------------
38
* Bugfix: Error on accessing unmanaged Imported/Computed tables (#336) PR #338

tests/TestFetch.m

+22
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,28 @@ function TestFetch_testNullable(testCase)
242242
testCase.verifyEqual(number(1), NaN);
243243
testCase.verifyEqual(blob{1}, '');
244244
end
245+
function TestFetch_testFetchn(testCase)
246+
st = dbstack;
247+
disp(['---------------' st(1).name '---------------']);
248+
% related to % https://github.com/datajoint/datajoint-matlab/issues/353
249+
package = 'University';
250+
251+
c1 = dj.conn(...
252+
testCase.CONN_INFO.host,...
253+
testCase.CONN_INFO.user,...
254+
testCase.CONN_INFO.password,'',true);
255+
256+
dj.createSchema(package,[testCase.test_root '/test_schemas'], ...
257+
[testCase.PREFIX '_university']);
258+
259+
q = University.A & 'id=999';
260+
testCase.verifyEqual(q.fetchn('id'), []);
261+
testCase.verifyEqual(q.fetchn('string'), {});
262+
testCase.verifyEqual(q.fetchn('datetime'), {});
263+
testCase.verifyEqual(q.fetchn('date'), {});
264+
testCase.verifyEqual(q.fetchn('number'), []);
265+
testCase.verifyEqual(q.fetchn('blob'), {});
266+
end
245267
function TestFetch_testDescribe(testCase)
246268
st = dbstack;
247269
disp(['---------------' st(1).name '---------------']);

0 commit comments

Comments
 (0)