datajoint-matlab
datajoint-matlab copied to clipboard
change the interpretation of `rel & {cond1, cond2}` from `AndList` to `OrList`
Until now, restricting by a list (or a set) resulted in the application of all the restrictions conjunctively , i.e. rel & {cond1, cond2}
was equivalent to rel & cond1 & cond2
or rel & dj.AndList(cond1, cond2)
.
I propose to change this interpretation to adjunction so that the above expression will be equivalent to rel & dj.OrList(cond1, cond2)
.
This change makes restrictions by lists logically consistent with the semijoin rel & otherRel
since otherRel
may be thought of as a set of conditions. Similarly, restrictions by an array of structures are also applied adjunctively.
This may cause problems in existing code base if anyone has restricted by cell arrays intending all the conditions to be met.
I agree with this change. Indeed this may break codes if it already depended on this behavior, but all in all cell list acting as or-list
is more consistent with how restriction with structure array works.
should be implemented with #77
In our documentation, it is explained as an OR List
https://docs.datajoint.io/matlab/queries/06-Restriction.html#restriction-by-a-table
In our documentation, it is explained as an OR List
https://docs.datajoint.io/matlab/queries/06-Restriction.html#restriction-by-a-table
Hi @shenshan - this is noted in the block: This section documents future intended behavior in MATLAB, which is contrary to current behavior. DataJoint for MATLAB has an open issue tracking this change.
which links to https://github.com/datajoint/datajoint-matlab/issues/128 , marked as duplicate of this issue. We should probably document both according to the version as part of the implementation plan
Is there a fix coming soon or a workaround for this? How can one make an OR list in MATLAB?
Hello - We're currently planning on this in the next release (3.5) - For the moment, there the following approaches:
- A structure array is interpreted as an OrList
- A struct with an array of values is interpreted as an OrList (e.g.
struct('some_id', [1, 2])
) - String based restriction using 'or' clauses e.g.
some_id=1 OR some_id=2
Thanks. That is very helpful. I didn't realize the 'OR' clauses worked like that. That will allow me to build OR queries with operators like '>' that are not supported in a struct.