Make failure in unions commutative

Right now, because of how _rearrange was implemented, a union with a subset
of attributes of another union could be united with it, but not viceversa.

This change makes both operations fail, hence making the union commutative
again.

Correct unions were always commutative.
This commit is contained in:
Salvo 'LtWorf' Tomaselli 2016-04-15 14:43:18 +02:00
parent 696361af4b
commit 7e61120beb

View File

@ -117,7 +117,7 @@ class Relation (object):
raise TypeError('Expected an instance of the same class')
elif self.header == other.header:
return other
elif self.header.sharedAttributes(other.header) == len(self.header):
elif len(self.header) == len(other.header) and self.header.sharedAttributes(other.header) == len(self.header):
return other.projection(self.header)
raise TypeError('Relations differ: [%s] [%s]' % (
','.join(self.header), ','.join(other.header)