From 7e61120beba1bf56a00d481e9df2a472796701b6 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Fri, 15 Apr 2016 14:43:18 +0200 Subject: [PATCH] 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. --- relational/relation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relational/relation.py b/relational/relation.py index c7d34f0..00d99f6 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -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)