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
14 changes: 7 additions & 7 deletions +dj/+internal/Header.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,25 @@ function project(self, params)

include = [self.attributes.iskey]; % always include the primary key
for iAttr=1:length(params)
if strcmp('*',params{iAttr})
if strcmp('*', params{iAttr})
include = include | true; % include all attributes
else
% process a renamed attribute
toks = regexp(params{iAttr}, ...
'^([a-z]\w*)\s*->\s*(\w+)', 'tokens');
if ~isempty(toks)
ix = find(strcmp(toks{1}{1},self.names));
ix = find(strcmp(toks{1}{1}, self.names));
if ~length(ix)
ix = find(strcmp(toks{1}{1},{self.attributes.alias}));
assert(length(ix)==1,'Attribute `%s` not found',toks{1}{1});
ix = find(strcmp(toks{1}{1}, {self.attributes.alias}));
assert(length(ix)==1, 'Attribute `%s` not found', toks{1}{1});
self.attributes(self.count + 1) = self.attributes(ix);
self.attributes(self.count).name = self.attributes(self.count).alias;
self.attributes(self.count).alias = '';
ix = self.count;
end
assert(length(ix)==1,'Attribute `%s` not found',toks{1}{1});
assert(~ismember(toks{1}{2},union({self.attributes.alias}, ...
self.names)), 'Duplicate attribute alias `%s`',toks{1}{2})
assert(length(ix)==1, 'Attribute `%s` not found', toks{1}{1});
assert(~ismember(toks{1}{2}, union({self.attributes.alias}, ...
self.names)), 'Duplicate attribute alias `%s`', toks{1}{2})
self.attributes(ix).name = toks{1}{2};
self.attributes(ix).alias = toks{1}{1};
else
Expand Down
2 changes: 1 addition & 1 deletion LNX-docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
interval: 1s
fakeservices.datajoint.io:
<<: *net
image: datajoint/nginx:v0.1.0
image: datajoint/nginx:v0.1.1
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
Expand Down
3 changes: 1 addition & 2 deletions local-docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
interval: 1s
fakeservices.datajoint.io:
<<: *net
image: datajoint/nginx:v0.1.0
image: datajoint/nginx:v0.1.1
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
Expand Down Expand Up @@ -132,7 +132,6 @@ services:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
## Additional mounts may go here
# - ./notebook:/home/muser/notebooks

# - ./matlab.prf:/tmp/matlab.prf
networks:
main:
6 changes: 4 additions & 2 deletions tests/TestDelete.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ function TestDelete_testTwoFKOnePK(testCase)
key.user_id = 'user1';
del(TestLab.User & key);

testCase.verifyEqual(length(fetch(TestLab.User & 'user_id != "user1"')), 2);
testCase.verifyEqual(length(fetch(TestLab.Duty & 'duty_second != "user1"')), 1);
testCase.verifyEqual(length(fetch(TestLab.User)), 2);
testCase.verifyEqual(length(fetch(TestLab.Duty)), 1);
testCase.verifyEqual(length(fetch(TestLab.User & 'user_id = "user1"')), 0);
testCase.verifyEqual(length(fetch(TestLab.Duty & 'duty_first = "user1" OR duty_second = "user1"')), 0);
end
end
end
28 changes: 28 additions & 0 deletions tests/TestProjection.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,34 @@ function TestProjection_testDateConversion(testCase)

res = q.fetch1('enrolled_date');
testCase.verifyEqual(res, '2018-01-24');

dj.config('safemode', 0);
drop(University.Student);
end
function TestProjection_testRenameSameKey(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']);

insert(University.Student, {
10 'Raphael' 'Guzman' datestr(datetime, 'yyyy-mm-dd HH:MM:SS')
11 'Shan' 'Shen' '2019-11-25 12:34:56'
12 'Joe' 'Schmoe' '2018-01-24 14:34:16'
});

q = proj(University.Student & 'first_name = "Raphael"', 'student_id->faculty_id', 'student_id->school_id');
testCase.verifyEqual(q.fetch('faculty_id', 'school_id'), struct('faculty_id', 10, 'school_id', 10));

dj.config('safemode', 0);
drop(University.Student);
end
end
end