Skip to content

Commit 9074cb8

Browse files
committed
add double projection test
update delete test bump nginx add whitespace after commas
1 parent 26cd5a8 commit 9074cb8

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

+dj/+internal/Header.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,25 @@ function project(self, params)
152152

153153
include = [self.attributes.iskey]; % always include the primary key
154154
for iAttr=1:length(params)
155-
if strcmp('*',params{iAttr})
155+
if strcmp('*', params{iAttr})
156156
include = include | true; % include all attributes
157157
else
158158
% process a renamed attribute
159159
toks = regexp(params{iAttr}, ...
160160
'^([a-z]\w*)\s*->\s*(\w+)', 'tokens');
161161
if ~isempty(toks)
162-
ix = find(strcmp(toks{1}{1},self.names));
162+
ix = find(strcmp(toks{1}{1}, self.names));
163163
if ~length(ix)
164-
ix = find(strcmp(toks{1}{1},{self.attributes.alias}));
165-
assert(length(ix)==1,'Attribute `%s` not found',toks{1}{1});
164+
ix = find(strcmp(toks{1}{1}, {self.attributes.alias}));
165+
assert(length(ix)==1, 'Attribute `%s` not found', toks{1}{1});
166166
self.attributes(self.count + 1) = self.attributes(ix);
167167
self.attributes(self.count).name = self.attributes(self.count).alias;
168168
self.attributes(self.count).alias = '';
169169
ix = self.count;
170170
end
171-
assert(length(ix)==1,'Attribute `%s` not found',toks{1}{1});
172-
assert(~ismember(toks{1}{2},union({self.attributes.alias}, ...
173-
self.names)), 'Duplicate attribute alias `%s`',toks{1}{2})
171+
assert(length(ix)==1, 'Attribute `%s` not found', toks{1}{1});
172+
assert(~ismember(toks{1}{2}, union({self.attributes.alias}, ...
173+
self.names)), 'Duplicate attribute alias `%s`', toks{1}{2})
174174
self.attributes(ix).name = toks{1}{2};
175175
self.attributes(ix).alias = toks{1}{1};
176176
else

LNX-docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ services:
2929
interval: 1s
3030
fakeservices.datajoint.io:
3131
<<: *net
32-
image: datajoint/nginx:v0.1.0
32+
image: datajoint/nginx:v0.1.1
3333
environment:
3434
- ADD_db_TYPE=DATABASE
3535
- ADD_db_ENDPOINT=db:3306

local-docker-compose.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ services:
3434
interval: 1s
3535
fakeservices.datajoint.io:
3636
<<: *net
37-
image: datajoint/nginx:v0.1.0
37+
image: datajoint/nginx:v0.1.1
3838
environment:
3939
- ADD_db_TYPE=DATABASE
4040
- ADD_db_ENDPOINT=db:3306
@@ -132,7 +132,6 @@ services:
132132
- /tmp/.X11-unix:/tmp/.X11-unix:rw
133133
## Additional mounts may go here
134134
# - ./notebook:/home/muser/notebooks
135-
136135
# - ./matlab.prf:/tmp/matlab.prf
137136
networks:
138137
main:

tests/TestDelete.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ function TestDelete_testTwoFKOnePK(testCase)
5959
key.user_id = 'user1';
6060
del(TestLab.User & key);
6161

62-
testCase.verifyEqual(length(fetch(TestLab.User & 'user_id != "user1"')), 2);
63-
testCase.verifyEqual(length(fetch(TestLab.Duty & 'duty_second != "user1"')), 1);
62+
testCase.verifyEqual(length(fetch(TestLab.User)), 2);
63+
testCase.verifyEqual(length(fetch(TestLab.Duty)), 1);
64+
testCase.verifyEqual(length(fetch(TestLab.User & 'user_id = "user1"')), 0);
65+
testCase.verifyEqual(length(fetch(TestLab.Duty & 'duty_first = "user1" OR duty_second = "user1"')), 0);
6466
end
6567
end
6668
end

tests/TestProjection.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ function TestProjection_testDateConversion(testCase)
2525

2626
res = q.fetch1('enrolled_date');
2727
testCase.verifyEqual(res, '2018-01-24');
28+
29+
dj.config('safemode', 0);
30+
drop(University.Student);
31+
end
32+
function TestProjection_testRenameSameKey(testCase)
33+
st = dbstack;
34+
disp(['---------------' st(1).name '---------------']);
35+
package = 'University';
36+
37+
c1 = dj.conn(...
38+
testCase.CONN_INFO.host,...
39+
testCase.CONN_INFO.user,...
40+
testCase.CONN_INFO.password,'',true);
41+
42+
dj.createSchema(package,[testCase.test_root '/test_schemas'], ...
43+
[testCase.PREFIX '_university']);
44+
45+
insert(University.Student, {
46+
10 'Raphael' 'Guzman' datestr(datetime, 'yyyy-mm-dd HH:MM:SS')
47+
11 'Shan' 'Shen' '2019-11-25 12:34:56'
48+
12 'Joe' 'Schmoe' '2018-01-24 14:34:16'
49+
});
50+
51+
q = proj(University.Student & 'first_name = "Raphael"', 'student_id->faculty_id', 'student_id->school_id');
52+
testCase.verifyEqual(q.fetch('faculty_id', 'school_id'), struct('faculty_id', 10, 'school_id', 10));
53+
54+
dj.config('safemode', 0);
55+
drop(University.Student);
2856
end
2957
end
3058
end

0 commit comments

Comments
 (0)