diff --git a/+dj/+internal/GeneralRelvar.m b/+dj/+internal/GeneralRelvar.m index d7d2a5bc..be241311 100644 --- a/+dj/+internal/GeneralRelvar.m +++ b/+dj/+internal/GeneralRelvar.m @@ -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 diff --git a/+dj/ERD.m b/+dj/ERD.m index c109c2e1..669894a0 100644 --- a/+dj/ERD.m +++ b/+dj/ERD.m @@ -75,7 +75,7 @@ case isnumeric(obj) n = length(ret.nodes); end otherwise - error 'invalid ERD difference' + error 'invalid ERD addition argument' end end @@ -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 @@ -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 diff --git a/+dj/struct.m b/+dj/struct.m index 22bed5e4..67c6999c 100644 --- a/+dj/struct.m +++ b/+dj/struct.m @@ -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); @@ -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}); diff --git a/docs-parts/computation/01-autopopulate_lang1.rst b/docs-parts/computation/01-autopopulate_lang1.rst index f2232ec6..6ecbf940 100644 --- a/docs-parts/computation/01-autopopulate_lang1.rst +++ b/docs-parts/computation/01-autopopulate_lang1.rst @@ -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 ` to be worked on. diff --git a/docs-parts/intro/Releases_lang1.rst b/docs-parts/intro/Releases_lang1.rst new file mode 100644 index 00000000..45b878b6 --- /dev/null +++ b/docs-parts/intro/Releases_lang1.rst @@ -0,0 +1 @@ +Start of Release Notes diff --git a/docs-parts/intro/empty.txt b/docs-parts/intro/empty.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/docs-parts/manipulation/3-Transactions_lang1.rst b/docs-parts/manipulation/3-Transactions_lang1.rst new file mode 100644 index 00000000..655f9741 --- /dev/null +++ b/docs-parts/manipulation/3-Transactions_lang1.rst @@ -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. +