def _fetch(self, query):
        """ Return data based on `query`. """
        self._setup(query)


        if query.vnames:
            tmp = []
            for name in self.metadata_names:
                if name in query.vnames:
                    tmp.append(name)
            self.metadata_names = tmp
            names = query.vnames
        else:
            if query.driver_name:
                #driver_info = self._drivers[self._driver_id]
                driver_info = self._drivers[self._driver_name]
                prefix = driver_info['prefix']
                all_names = [prefix+name
                             for name in driver_info['recording']]
            else:
                all_names = []
                for driver_info in self._drivers.values():
                    prefix = driver_info['prefix']
                    all_names.extend([prefix+name
                                      for name in driver_info['recording']])
            names = sorted(all_names+self.metadata_names)

        if query.names:
            # Returning single row, not list of rows.
            return names

        nan = float('NaN')
        rows = ListResult()
        state = {}  # Retains last seen values.
        for case_data in self._reader.cases():
            data = case_data['data']
            metadata = case_data['metadata']
            case_id = metadata['_id']
            case_driver_id = metadata['_driver_id']
            case_driver_name = metadata['_driver_name']
            case_itername = metadata['_itername']

            prefix = self._drivers[case_driver_name]['prefix']
            #prefix = self._drivers[case_driver_id]['prefix']
            if prefix:
                # Make names absolute.
                pass
                #data = dict([(prefix+name, value)
                 #            for name, value in data.items()])
            else:
                data = data.copy()  # Don't modify reader version.

            state.update(data)

            # Filter on driver.
            if self._driver_name is not None and \
               case_driver_name != self._driver_name:
                continue
            #if self._driver_id is not None and \
               #case_driver_id != self._driver_id:
                #continue

            ## Filter on case.
            #if self._case_ids is None or case_id in self._case_ids:
            if self._case_iternames is None or case_itername in self._case_iternames:
                for name in self.metadata_names:
                    data[name] = case_data['metadata'][name]

                row = DictList(names)
                for name in names:
                    if query.local_only:
                        if self.metadata_names in name:
                            row.append(data[name])
                        else:
                            driver = self._drivers[case_driver_name]
                            # driver = self._drivers[case_driver_id]
                            lnames = [prefix+rec for rec in driver['recording']]
                            if name in lnames:
                                row.append(data[name])
                            else:
                                row.append(nan)
                    elif name in state:
                        row.append(state[name])
                    elif name in data:
                        row.append(data[name])
                    else:
                        row.append(nan)
                rows.append(row)

            #if case_id == self._query_id or case_id == self._parent_id:
                #break  # Parent is last case recorded.
            if case_itername == self._query_itername or case_itername == self._parent_itername:
                break  # Parent is last case recorded.

        if self._query_id and not rows:
            raise ValueError('No case with _id %s' % self._query_id)

        if query.transpose:
            tmp = DictList(names)
            for i in range(len(rows[0])):
                tmp.append([row[i] for row in rows])
            # Keep CDS as attribute for post-processing
            tmp.cds = self
            return tmp

        # Keep CDS as attribute for post-processing
        rows.cds = self
        return rows
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/casehandlers/query_hdf5.py/CaseDatasetHDF5._fetch/swapped operands of `in`