Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datajoint/relational_operand.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def __init__(self, arg, *attributes, **renamed_attributes):
else:
self._attributes.append(attribute)

if arg.heading.computed:
if arg.heading.computed or arg.restrictions:
self._arg = Subquery(arg)
else:
self._arg = arg
Expand Down
12 changes: 12 additions & 0 deletions tests/test_relational_operand.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ def test_project():
assert_equal(set(x.heading.names), set(('id_a', 'a')),
'extend does not work')

# projection after restriction
assert_equal(
len(D() & (L() & 'cond_in_l')) + len(D() - (L() & 'cond_in_l')),
len(D()),
'failed semijoin or antijoin'
)
assert_equal(
len((D() - (L() & 'cond_in_l')).project()),
len(D() - (L() & 'cond_in_l')),
'projection altered the cardinality of a restricted relation'
)

@staticmethod
def test_aggregate():
x = B().aggregate(C(), 'n', count='count(id_c)', mean='avg(value)', max='max(value)')
Expand Down