Open dimitri-yatsenko opened 7 years ago
An alternative suggestion for the syntax.
search = self.search(key) # create the search object
nslices = search['nslices'] # fetch nslices
# tables containing the attributes are joined if they are in the same search call
traces, rois = search['trace', 'roi'] # fetch matched traces and ROIs from different tables
I like it. This will allow more portable code that relies on descriptive attribute names and survives changes in the schema design.
Another discussion and a different syntax.
nslices = (self & key).search1['nslices'] # fetch nslices as a scalar.
# tables containing the attributes are joined if they are in the same search call
traces, rois = (self & key).search['trace', 'roi'] # fetch matched traces and ROIs from different tables
Another syntax
search = self.search(key)
nslices = search.fetch1['nslices'] # fetch nslices as a scalar.
# tables containing the attributes are joined if they are in the same search call
traces, rois = search.fetch['trace', 'roi']
Another syntax
nslices = self.get1(key, ['nslices']) # fetch nslices as a scalar.
# tables containing the attributes are joined if they are in the same search call
traces, rois = self.get(key, ['trace', 'roi'])
Between the last two, I'd prefer the search.fetch1
and search.fetch
syntax, allowing us to not repeat key
argument.
I agree with @eywalker although I'd still prefer to rename search
into something else.
Do we have running candidates on what to rename search
to?
I propose farfetch
. It's catchy and conveys its unusual power.
nslices = (rel & key).farfetch1['nslices']
traces = (rel & key).farfetch['traces']
Within
_make_tuples
functions, it may be possible to automate query formation for fetching data that can be uniquely identified by its attribute name.For example,
would be replaced with
This is intended to work from
_make_tuples
only since it will need to know its place in the data hierarchy and the value ofkey
.