@@ -34,11 +34,16 @@ addAttribute attr attrs = attrs `V.snoc` attr
3434
3535--if some attribute names overlap but the types do not, then spit back an error
3636joinAttributes :: Attributes -> Attributes -> Either RelationalError Attributes
37−joinAttributes attrs1 attrs2 = if V.length (vectorUniqueify overlappingAttributes) /= V.length overlappingAttributes then
37+joinAttributes attrs1 attrs2 = if V.length uniqueOverlappingAttributes /= V.length overlappingAttributes then
3838 Left $ TupleAttributeTypeMismatchError overlappingAttributes
39− else
40− Right $ vectorUniqueify (attrs1 V.++ attrs2)
39+ else if V.length overlappingAttrsDifferentTypes > 0 then
40+ Left (TupleAttributeTypeMismatchError overlappingAttrsDifferentTypes)
41+ else
42+ Right $ vectorUniqueify (attrs1 V.++ attrs2)
4143 where
44+ overlappingAttrsDifferentTypes = V.filter (\attr -> V.elem (attributeName attr) attrNames2 && V.notElem attr attrs2) attrs1
45+ attrNames2 = V.map attributeName attrs2
46+ uniqueOverlappingAttributes = vectorUniqueify overlappingAttributes
4247 overlappingAttributes = V.filter (\attr -> V.elem attr attrs2) attrs1
4348
4449addAttributes :: Attributes -> Attributes -> Attributes