@@ -34,11 +34,16 @@ addAttribute attr attrs = attrs `V.snoc` attr
35--if some attribute names overlap but the types do not, then spit back an error
35--if some attribute names overlap but the types do not, then spit back an error
36joinAttributes :: Attributes -> Attributes -> Either RelationalError Attributes
36joinAttributes :: 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
38 Left $ TupleAttributeTypeMismatchError overlappingAttributes
38 Left $ TupleAttributeTypeMismatchError overlappingAttributes
39− else
39+ else if V.length overlappingAttrsDifferentTypes > 0 then
40+ Left (TupleAttributeTypeMismatchError overlappingAttrsDifferentTypes)
40− Right $ vectorUniqueify (attrs1 V.++ attrs2)
42+ Right $ vectorUniqueify (attrs1 V.++ attrs2)
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
42 overlappingAttributes = V.filter (\attr -> V.elem attr attrs2) attrs1
47 overlappingAttributes = V.filter (\attr -> V.elem attr attrs2) attrs1
44addAttributes :: Attributes -> Attributes -> Attributes
49addAttributes :: Attributes -> Attributes -> Attributes