From 7770441901efdfef3e7f3f4d2152f4af679d6382 Mon Sep 17 00:00:00 2001 From: Fabian Sinz Date: Mon, 5 Oct 2015 16:35:44 -0500 Subject: [PATCH 1/4] before throwing out YuEtAl2009 --- datajoint/fetch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/datajoint/fetch.py b/datajoint/fetch.py index 395885528..0cb6d6776 100644 --- a/datajoint/fetch.py +++ b/datajoint/fetch.py @@ -283,7 +283,10 @@ def __getitem__(self, item): single_output = isinstance(item, str) or item is PRIMARY_KEY or isinstance(item, int) item, attributes = prepare_attributes(self._relation, item) - result = self._relation.project(*attributes).fetch() + result = self._relation.project(*attributes) + assert len(result) == 1, 'Fetch1 should only return one tuple' + result = result.fetch() + return_values = tuple( np.ndarray(result.shape, np.dtype({name: result.dtype.fields[name] for name in self._relation.primary_key}), From 5c71e0507beec9fb1387673dc38c6d608a894a67 Mon Sep 17 00:00:00 2001 From: Fabian Sinz Date: Tue, 13 Oct 2015 09:42:56 -0500 Subject: [PATCH 2/4] fix join fetchall bug --- datajoint/heading.py | 2 +- datajoint/relational_operand.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/datajoint/heading.py b/datajoint/heading.py index 7a742416b..a08e3f3af 100644 --- a/datajoint/heading.py +++ b/datajoint/heading.py @@ -230,7 +230,7 @@ def project(self, *attribute_list, **renamed_attributes): def join(self, other, left): """ - join two headings + Joins two headings. """ assert isinstance(other, Heading) attribute_list = [v._asdict() for v in self.attributes.values()] diff --git a/datajoint/relational_operand.py b/datajoint/relational_operand.py index 3ee4e3bf4..bce70f986 100644 --- a/datajoint/relational_operand.py +++ b/datajoint/relational_operand.py @@ -2,7 +2,7 @@ import numpy as np import abc import re -from copy import copy +from copy import copy, deepcopy import logging from . import DataJointError @@ -339,7 +339,7 @@ def from_clause(self): @property def select_fields(self): - return '*' + return self.heading.as_sql class Projection(RelationalOperand): From 085f453b96d3eef1c7de645a86b5d582a1ab68e2 Mon Sep 17 00:00:00 2001 From: Fabian Sinz Date: Wed, 14 Oct 2015 09:12:05 -0500 Subject: [PATCH 3/4] Removed unnecessary import --- datajoint/relational_operand.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datajoint/relational_operand.py b/datajoint/relational_operand.py index bce70f986..f3e25b0d2 100644 --- a/datajoint/relational_operand.py +++ b/datajoint/relational_operand.py @@ -2,7 +2,7 @@ import numpy as np import abc import re -from copy import copy, deepcopy +from copy import copy import logging from . import DataJointError From 3dcd96a5d7e0722c45356506975a37a6b23794ec Mon Sep 17 00:00:00 2001 From: Fabian Sinz Date: Wed, 14 Oct 2015 10:04:03 -0500 Subject: [PATCH 4/4] incorporated Dimitri's comments --- datajoint/fetch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datajoint/fetch.py b/datajoint/fetch.py index 2e9530757..4474482ac 100644 --- a/datajoint/fetch.py +++ b/datajoint/fetch.py @@ -279,9 +279,9 @@ def __getitem__(self, item): single_output = isinstance(item, str) or item is PRIMARY_KEY or isinstance(item, int) item, attributes = prepare_attributes(self._relation, item) - result = self._relation.project(*attributes) - assert len(result) == 1, 'Fetch1 should only return one tuple' - result = result.fetch() + result = self._relation.project(*attributes).fetch() + if len(result) != 1: + raise DataJointError('Fetch1 should only return one tuple') return_values = tuple( np.ndarray(result.shape,