datajoint-matlab icon indicating copy to clipboard operation
datajoint-matlab copied to clipboard

change the interpretation of `rel & {cond1, cond2}` from `AndList` to `OrList`

Open dimitri-yatsenko opened this issue 7 years ago • 8 comments

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.

dimitri-yatsenko avatar Apr 28 '17 05:04 dimitri-yatsenko

This may cause problems in existing code base if anyone has restricted by cell arrays intending all the conditions to be met.

dimitri-yatsenko avatar Apr 28 '17 05:04 dimitri-yatsenko

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.

eywalker avatar Apr 28 '17 05:04 eywalker

should be implemented with #77

ixcat avatar Apr 28 '20 20:04 ixcat

In our documentation, it is explained as an OR List

https://docs.datajoint.io/matlab/queries/06-Restriction.html#restriction-by-a-table

shenshan avatar Aug 10 '20 23:08 shenshan

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

ixcat avatar Aug 11 '20 00:08 ixcat

Is there a fix coming soon or a workaround for this? How can one make an OR list in MATLAB?

SchwartzNU avatar Dec 25 '20 03:12 SchwartzNU

Hello - We're currently planning on this in the next release (3.5) - For the moment, there the following approaches:

  1. A structure array is interpreted as an OrList
  2. A struct with an array of values is interpreted as an OrList (e.g. struct('some_id', [1, 2]))
  3. String based restriction using 'or' clauses e.g. some_id=1 OR some_id=2

ixcat avatar Dec 28 '20 16:12 ixcat

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.

SchwartzNU avatar Dec 28 '20 16:12 SchwartzNU