on master help sign in
fix type checking in attribute equality restrictions
f1f00f7AgentM
ProjectM36/Attribute.hs+1−1
@@ -17,7 +17,7 @@ null :: Attributes -> Bool
17null = V.null
17null = V.null
18
18
19attributesFromList :: [Attribute] -> Attributes
19attributesFromList :: [Attribute] -> Attributes
20−attributesFromList = V.fromList -- . L.nub
20+attributesFromList = V.fromList -- . L.nub --too expensive
21
21
22attributeName :: Attribute -> AttributeName
22attributeName :: Attribute -> AttributeName
23attributeName (Attribute name _) = name
23attributeName (Attribute name _) = name
ProjectM36/RelationalExpression.hs+11−5
@@ -378,12 +378,18 @@ predicateRestrictionFilter context _ (RelationalExprPredicate relExpr) = case ru
378 else
378 else
379 Left $ PredicateExpressionError "Relational restriction filter must evaluate to 'true' or 'false'"
379 Left $ PredicateExpressionError "Relational restriction filter must evaluate to 'true' or 'false'"
380
380
381−predicateRestrictionFilter context _ (AttributeEqualityPredicate attrName atomexpr) = Right $ \tupleIn -> case atomForAttributeName attrName tupleIn of
381+predicateRestrictionFilter context attrs (AttributeEqualityPredicate attrName atomExpr) = do
382− Left _ -> False
382+ attr <- A.attributeForName attrName attrs
383− Right atomIn ->
383+ atomExprType <- typeFromAtomExpr attrs context atomExpr
384− case evalAtomExpr tupleIn context atomexpr of
384+ if atomExprType /= A.atomType attr then
385+ Left $ TupleAttributeTypeMismatchError (A.attributesFromList [attr])
386+ else
387+ Right $ \tupleIn -> case atomForAttributeName attrName tupleIn of
385 Left _ -> False
388 Left _ -> False
389+ Right atomIn ->
390+ case evalAtomExpr tupleIn context atomExpr of
391+ Left _ -> False
386− Right atomCmp -> atomCmp == atomIn
392+ Right atomCmp -> atomCmp == atomIn
387
393
388-- in the future, it would be useful to do typechecking on the attribute and atom expr filters in advance
394-- in the future, it would be useful to do typechecking on the attribute and atom expr filters in advance
389predicateRestrictionFilter context attrs (AtomExprPredicate atomExpr) = do
395predicateRestrictionFilter context attrs (AtomExprPredicate atomExpr) = do