diff --git a/datajoint/relational_operand.py b/datajoint/relational_operand.py index f3e25b0d2..cd2f180d9 100644 --- a/datajoint/relational_operand.py +++ b/datajoint/relational_operand.py @@ -4,7 +4,7 @@ import re from copy import copy import logging -from . import DataJointError +from . import DataJointError, config from .fetch import Fetch, Fetch1 @@ -17,6 +17,7 @@ class AndList(Sequence): Each restriction can be a list or set or a relation whose elements are ORed. But the elements that are lists can contain """ + def __init__(self, heading): self.heading = heading self._list = [] @@ -41,6 +42,7 @@ def where_clause(self): """ convert to a WHERE clause string """ + def make_condition(arg, _negate=False): if isinstance(arg, (str, AndList)): return str(arg), _negate @@ -51,12 +53,12 @@ def make_condition(arg, _negate=False): if not common_attributes: condition = 'FALSE' if negate else 'TRUE' else: - common_attributes = '`'+'`,`'.join(common_attributes)+'`' + common_attributes = '`' + '`,`'.join(common_attributes) + '`' condition = '({fields}) {not_}in ({subquery})'.format( fields=common_attributes, not_="not " if negate else "", subquery=arg.make_select(common_attributes)) - return condition, False # negate is cleared + return condition, False # negate is cleared # mappings are turned into ANDed equality conditions if isinstance(arg, Mapping): @@ -244,6 +246,33 @@ def __repr__(self): ret += ' & %r' % self._restrictions return ret + def _repr_html_(self): + limit = config['display.limit'] + rel = self.project(*self.heading.non_blobs) # project out blobs + columns = rel.heading.names + content = dict( + head='
| + %(head)s + | +
|---|
%(tuples)i tuples
\n