Skip to content

Commit edd7eb0

Browse files
authored
Merge pull request #427 from datajoint/stage-dashed-schemas
Allow dashed schemas
2 parents e6bf304 + 204327a commit edd7eb0

10 files changed

+28
-17
lines changed

+dj/+internal/GeneralRelvar.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ case isa(cond, 'dj.internal.GeneralRelvar')
951951
for j = 1:length(data)
952952
if ~isempty(data(j).(attr(i).name))
953953
uuid = reshape(lower(dec2hex(data(j).(attr(i).name))).',1,[]);
954-
data(j).(attr(i).name) = connection.schemas.(...
954+
data(j).(attr(i).name) = connection.schemas(...
955955
attr(i).database).external.table(...
956956
attr(i).store).download_buffer(uuid);
957957
end

+dj/Connection.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
end
4242
self.foreignKeys = struct([]);
4343
self.packages = containers.Map;
44-
self.schemas = struct();
44+
self.schemas = containers.Map;
4545
end
4646

4747

4848
function register(self, schema)
49-
self.schemas.(schema.dbname) = schema;
49+
self.schemas(schema.dbname) = schema;
5050
end
5151

5252
function addPackage(self, dbname, package)

+dj/createSchema.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ function createSchema(package, parentdir, db)
1414

1515
if ~dbname
1616
disp 'No database name entered. Quitting.'
17-
elseif isempty(regexp(dbname,'^[a-z][a-z0-9_]*$','once'))
18-
error(['Invalid database name. Begin with a letter, only lowercase alphanumerical and ' ...
19-
'underscores.'])
17+
elseif isempty(regexp(dbname,'^[a-z][a-z0-9_\-]*$','once'))
18+
error(['Invalid database name. Valid name must begin with a letter and include ' ...
19+
'only lowercase alphanumerical, dashes, and underscores.'])
2020
else
2121
% create database
2222
s = query(dj.conn, ...
@@ -26,7 +26,7 @@ function createSchema(package, parentdir, db)
2626
if ~isempty(s.schema_name)
2727
disp 'database already exists'
2828
else
29-
query(dj.conn, sprintf('create schema %s',dbname))
29+
query(dj.conn, sprintf('CREATE SCHEMA `%s`',dbname))
3030
disp 'database created'
3131
end
3232

+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', 5, 'bugfix', 0);
4+
v = struct('major', 3, 'minor', 5, 'bugfix', 1);
55

66
if nargout
77
varargout{1}=v;

.github/workflows/development.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ jobs:
3737
COMPOSE_HTTP_TIMEOUT: "120"
3838
run: |
3939
docker-compose -f LNX-docker-compose.yaml up --build --exit-code-from app
40+
- name: Add toolbox artifact
41+
uses: actions/upload-artifact@v3
42+
with:
43+
name: dj-toolbox-${{matrix.matlab_version}}
44+
path: DataJoint.mltbx
45+
retention-days: 1
4046
publish-docs:
4147
if: |
4248
github.event_name == 'push' &&

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
44
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
55

6+
## [3.5.1] - 2023-03-27
7+
8+
+ Bugfix: Allow schemas named with dashes
9+
610
## [3.5.0] - 2022-03-21
711

812
+ Bugfix: Cascading delete for renamed foreign keys (#379) PR #386
913
+ Minor: Add renaming the same attribute multiple times within a single projection PR #386
1014
+ Minor: Add config for reading values with 32-bit dimensions (datajoint/mym#86) PR #395
1115

12-
[3.5.0]: https://github.com/datajoint/element-deeplabcut/releases/tag/3.5.0
16+
[3.5.1]: https://github.com/datajoint/datajoint-matlab/compare/v3.5.0...v3.5.1
17+
[3.5.0]: https://github.com/datajoint/datajoint-matlab/releases/tag/v3.5.0

LNX-docker-compose.yaml

+2-2
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 --exit-code-from app --build
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: datajoint/nginx:v0.1.1
32+
image: datajoint/nginx:v0.2.4
3333
environment:
3434
- ADD_db_TYPE=DATABASE
3535
- ADD_db_ENDPOINT=db:3306

local-docker-compose.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# docker-compose -f local-docker-compose.yaml --env-file LNX.env up --build
1+
# docker compose -f local-docker-compose.yaml --env-file LNX.env up --build
22
version: '2.4'
33
x-net: &net
44
networks:
@@ -34,7 +34,7 @@ services:
3434
interval: 1s
3535
fakeservices.datajoint.io:
3636
<<: *net
37-
image: datajoint/nginx:v0.1.1
37+
image: datajoint/nginx:v0.2.4
3838
environment:
3939
- ADD_db_TYPE=DATABASE
4040
- ADD_db_ENDPOINT=db:3306

tests/Prep.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ function dispose(testCase)
115115
curr_conn.query('SET FOREIGN_KEY_CHECKS=0;');
116116
res = curr_conn.query(['SHOW DATABASES LIKE "' testCase.PREFIX '_%";']);
117117
for i = 1:length(res.(['Database (' testCase.PREFIX '_%)']))
118-
curr_conn.query(['DROP DATABASE ' ...
119-
res.(['Database (' testCase.PREFIX '_%)']){i} ';']);
118+
curr_conn.query(['DROP DATABASE `' ...
119+
res.(['Database (' testCase.PREFIX '_%)']){i} '`;']);
120120
end
121121
curr_conn.query('SET FOREIGN_KEY_CHECKS=1;');
122122

tests/TestSchema.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ function TestSchema_testNew(testCase)
100100
% setup
101101
dj.config.restore;
102102
dj.config('safemode', false);
103-
dj.new('new.Student', 'M', pwd , 'djtest_new');
104-
rmdir('+new', 's');
103+
dj.new('new_space.Student', 'M', pwd , 'djtest_new-space');
104+
rmdir('+new_space', 's');
105105
end
106106
function TestSchema_testVirtual(testCase)
107107
st = dbstack;

0 commit comments

Comments
 (0)