on master help sign in
fix critical bug in relvar assignment due to stale attributes comparison

the bug compared attribute vectors directly which prevented

commit85c4dc99b59a13337b28fc739523bc44a5af2291 authorAgentM <agentm@themactionfaction.com> dateMon 8 Jun 2015, 09:57 (11 years ago) parent0e0c0b5
2 files changed+6−4
ProjectM36/Error.hs+2−2 ProjectM36/RelationalExpression.hs+4−2
ProjectM36/Error.hs+2−2
@@ -9,7 +9,7 @@ import GHC.Generics (Generic)
99import qualified Data.Text as T
1010
1111
12−data RelationalError = NoSuchAttributeNameError AttributeName
12+data RelationalError = NoSuchAttributeNamesError (S.Set AttributeName)
1313 | TupleAttributeCountMismatchError Int --attribute name
1414 | TupleAttributeTypeMismatchError Attributes
1515 | AttributeCountMismatchError Int
@@ -18,7 +18,7 @@ data RelationalError = NoSuchAttributeNameError AttributeName
1818 | AttributeIsNotRelationValuedError AttributeName
1919 | RelVarNotDefinedError RelVarName
2020 | RelVarAlreadyDefinedError RelVarName
21− | RelVarAssignmentTypeMismatchError
21+ | RelVarAssignmentTypeMismatchError Attributes Attributes --expected, found
2222 | InclusionDependencyCheckError IncDepName
2323 | ParseError T.Text
2424 | PredicateExpressionError T.Text
ProjectM36/RelationalExpression.hs+4−2
@@ -223,10 +223,12 @@ evalContextExpr (Assign relVarName expr) = do
223223 Left err -> return $ Just err
224224 Right rel -> case existingRelVar of
225225 Nothing -> setRelVar relVarName rel
226− Just existingRel -> if attributes existingRel == attributes rel then
226+ Just existingRel -> let expectedAttributes = attributes existingRel
227+ foundAttributes = attributes rel in
228+ if A.attributesEqual expectedAttributes foundAttributes then
227229 setRelVar relVarName rel
228230 else
229− return $ Just RelVarAssignmentTypeMismatchError
231+ return $ Just (RelVarAssignmentTypeMismatchError expectedAttributes foundAttributes)
230232
231233evalContextExpr (Insert relVarName relExpr) = evalContextExpr $ Assign relVarName (Union relExpr (RelationVariable relVarName))
232234