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
8 changes: 7 additions & 1 deletion +dj/+internal/GeneralRelvar.m
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,13 @@ case isa(cond, 'dj.internal.GeneralRelvar')
else
assert((isnumeric(value) || islogical(value)) && isscalar(value), ...
'Value for key.%s must be a numeric scalar', field{1});
value=sprintf('%1.16g', value);
if isa(value, 'uint64')
value = sprintf('%u', value);
elseif isa(value, 'int64')
value = sprintf('%i', value);
else
value = sprintf('%1.16g', value);
end
end
subcond = sprintf('%s AND `%s`=%s', subcond, field{1}, value);
end
Expand Down
12 changes: 9 additions & 3 deletions +dj/ERD.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ case isnumeric(obj)
n = length(ret.nodes);
end
otherwise
error 'invalid ERD difference'
error 'invalid ERD addition argument'
end
end

Expand All @@ -99,11 +99,16 @@ case isnumeric(obj)
n = length(ret.nodes);
end
otherwise
error 'invalid ERD difference'
error 'invalid ERD difference argument'
end
end


function display(self)
self.draw
end


function draw(self)
% draw the diagram

Expand Down Expand Up @@ -141,7 +146,8 @@ function draw(self)
isPart = tiers(i)==6;
fs = dj.set('erdFontSize')*(1 - 0.3*isPart);
fc = isPart*0.3*[1 1 1];
text(h.XData(i)+0.1,h.YData(i), self.conn.tableToClass(self.graph.Nodes.Name{i}), ...
name = self.conn.tableToClass(self.graph.Nodes.Name{i});
text(h.XData(i)+0.1, h.YData(i), name, ...
'fontsize', fs, 'rotation', -16, 'color', fc, ...
'Interpreter', 'none');
end
Expand Down
3 changes: 2 additions & 1 deletion +dj/struct.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
function s = fromFields(s)
% DJ.STRUCT.FROMFIELDS - construct a structure array from a
% scalar structure whose fields contain same-sized arrays of values.
assert(isscalar(s) && isstruct(s), 'the input must be a scalar structure')

fnames = fieldnames(s)';
lst = cell(1,length(fnames)*2);
Expand All @@ -151,7 +152,7 @@
if isempty(v)
lst{i*2}={};
else
if isnumeric(v) || islogical(v)
if isnumeric(v) || islogical(v) || isstring(v)
lst{i*2} = num2cell(s.(fnames{i}));
else
lst{i*2} = s.(fnames{i});
Expand Down
4 changes: 4 additions & 0 deletions docs-parts/computation/01-autopopulate_lang1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
end
end
end

.. note:: Currently matlab uses ``makeTuples`` rather than ``make``. This will be fixed in an upcoming release: https://github.com/datajoint/datajoint-matlab/issues/141

The ``make`` method receives one argument: the struct ``key`` containing the primary key value of an element of :ref:`key source <keysource>` to be worked on.
1 change: 1 addition & 0 deletions docs-parts/intro/Releases_lang1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Start of Release Notes
Empty file removed docs-parts/intro/empty.txt
Empty file.
33 changes: 33 additions & 0 deletions docs-parts/manipulation/3-Transactions_lang1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Transactions are formed using the methods ``startTransaction``, ``cancelTransaction``, and ``commitTransaction`` of a connection object.
A connection object may obtained from any table object.

For example, the following code inserts matching entries for the master table ``Session`` and its part table ``SessionExperimenter``.

.. code-block:: matlab

% get the connection object
session = Session
connection = session.conn

% insert Session and Session.Experimenter entries in a transaction
connection.startTransaction
try
key.subject_id = animal_id;
key.session_time = session_time;

session_entry = key;
session_entry.brain_region = region;
insert(Session, session_entry)

experimenter_entry = key;
experimenter_entry.experimenter = username;
insert(SessionExperimenter, experiment_entry)
connection.commitTransaction
catch
connection.cancelTransaction
end


Here, to external observers, both inserts will take effect together only upon exiting from the ``try-catch`` block or will not have any effect at all.
For example, if the second insert fails due to an error, the first insert will be rolled back.