Skip to content

Commit

Permalink
Merge pull request #427 from datajoint/stage-dashed-schemas
Browse files Browse the repository at this point in the history
Allow dashed schemas
  • Loading branch information
yambottle committed Mar 27, 2023
2 parents e6bf304 + 204327a commit edd7eb0
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion +dj/+internal/GeneralRelvar.m
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ case isa(cond, 'dj.internal.GeneralRelvar')
for j = 1:length(data)
if ~isempty(data(j).(attr(i).name))
uuid = reshape(lower(dec2hex(data(j).(attr(i).name))).',1,[]);
data(j).(attr(i).name) = connection.schemas.(...
data(j).(attr(i).name) = connection.schemas(...
attr(i).database).external.table(...
attr(i).store).download_buffer(uuid);
end
Expand Down
4 changes: 2 additions & 2 deletions +dj/Connection.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
end
self.foreignKeys = struct([]);
self.packages = containers.Map;
self.schemas = struct();
self.schemas = containers.Map;
end


function register(self, schema)
self.schemas.(schema.dbname) = schema;
self.schemas(schema.dbname) = schema;
end

function addPackage(self, dbname, package)
Expand Down
8 changes: 4 additions & 4 deletions +dj/createSchema.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ function createSchema(package, parentdir, db)

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

Expand Down
2 changes: 1 addition & 1 deletion +dj/version.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function varargout = version
% report DataJoint version

v = struct('major', 3, 'minor', 5, 'bugfix', 0);
v = struct('major', 3, 'minor', 5, 'bugfix', 1);

if nargout
varargout{1}=v;
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
COMPOSE_HTTP_TIMEOUT: "120"
run: |
docker-compose -f LNX-docker-compose.yaml up --build --exit-code-from app
- name: Add toolbox artifact
uses: actions/upload-artifact@v3
with:
name: dj-toolbox-${{matrix.matlab_version}}
path: DataJoint.mltbx
retention-days: 1
publish-docs:
if: |
github.event_name == 'push' &&
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [3.5.1] - 2023-03-27

+ Bugfix: Allow schemas named with dashes

## [3.5.0] - 2022-03-21

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

[3.5.0]: https://github.com/datajoint/element-deeplabcut/releases/tag/3.5.0
[3.5.1]: https://github.com/datajoint/datajoint-matlab/compare/v3.5.0...v3.5.1
[3.5.0]: https://github.com/datajoint/datajoint-matlab/releases/tag/v3.5.0
4 changes: 2 additions & 2 deletions LNX-docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# docker-compose -f LNX-docker-compose.yaml --env-file LNX.env up --exit-code-from app --build
# docker compose -f LNX-docker-compose.yaml --env-file LNX.env up --exit-code-from app --build
version: '2.2'
x-net: &net
networks:
Expand Down Expand Up @@ -29,7 +29,7 @@ services:
interval: 1s
fakeservices.datajoint.io:
<<: *net
image: datajoint/nginx:v0.1.1
image: datajoint/nginx:v0.2.4
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
Expand Down
4 changes: 2 additions & 2 deletions local-docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# docker-compose -f local-docker-compose.yaml --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:
Expand Down Expand Up @@ -34,7 +34,7 @@ services:
interval: 1s
fakeservices.datajoint.io:
<<: *net
image: datajoint/nginx:v0.1.1
image: datajoint/nginx:v0.2.4
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
Expand Down
4 changes: 2 additions & 2 deletions tests/Prep.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ function dispose(testCase)
curr_conn.query('SET FOREIGN_KEY_CHECKS=0;');
res = curr_conn.query(['SHOW DATABASES LIKE "' testCase.PREFIX '_%";']);
for i = 1:length(res.(['Database (' testCase.PREFIX '_%)']))
curr_conn.query(['DROP DATABASE ' ...
res.(['Database (' testCase.PREFIX '_%)']){i} ';']);
curr_conn.query(['DROP DATABASE `' ...
res.(['Database (' testCase.PREFIX '_%)']){i} '`;']);
end
curr_conn.query('SET FOREIGN_KEY_CHECKS=1;');

Expand Down
4 changes: 2 additions & 2 deletions tests/TestSchema.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ function TestSchema_testNew(testCase)
% setup
dj.config.restore;
dj.config('safemode', false);
dj.new('new.Student', 'M', pwd , 'djtest_new');
rmdir('+new', 's');
dj.new('new_space.Student', 'M', pwd , 'djtest_new-space');
rmdir('+new_space', 's');
end
function TestSchema_testVirtual(testCase)
st = dbstack;
Expand Down

0 comments on commit edd7eb0

Please sign in to comment.