@@ -66,21 +66,55 @@ sin nullability (toList -> as) a = case nullability of
66 (Opaleye.ListExpr (toPrimExpr <$> xs))
66 (Opaleye.ListExpr (toPrimExpr <$> xs))
69+-- | Compare two expressions for equality.
71+-- This corresponds to the SQL @IS NOT DISTINCT FROM@ operator, and will equate
72+-- @null@ values as @true@. This differs from @=@ which would return @null@.
73+-- This operator matches Haskell's '==' operator. For an operator identical to
74+-- SQL @=@, see '==?'.
69(==.) :: Sql DBEq a => Expr a -> Expr a -> Expr Bool
75(==.) :: Sql DBEq a => Expr a -> Expr a -> Expr Bool
70(==.) = seq nullabilization
76(==.) = seq nullabilization
71infix 4 ==.
77infix 4 ==.
80+-- | Test if two expressions are different (not equal).
82+-- This corresponds to the SQL @IS DISTINCT FROM@ operator, and will return
83+-- @false@ when comparing two @null@ values. This differs from ordinary @=@
84+-- which would return @null@. This operator is closer to Haskell's '=='
85+-- operator. For an operator identical to SQL @=@, see '/=?'.
74(/=.) :: Sql DBEq a => Expr a -> Expr a -> Expr Bool
86(/=.) :: Sql DBEq a => Expr a -> Expr a -> Expr Bool
75(/=.) = sne nullabilization
87(/=.) = sne nullabilization
76infix 4 /=.
88infix 4 /=.
91+-- | Test if two expressions are equal. This operator is usually the best
92+-- choice when forming join conditions, as PostgreSQL has a much harder time
93+-- optimizing a join that has multiple 'True' conditions.
95+-- This corresponds to the SQL @=@ operator, though it will always return a
98+-- >>> select c $ pure $ lit Nothing ==? lit True
101+-- >>> select c $ pure $ lit Nothing ==? lit Nothing
79(==?) :: DBEq a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
103(==?) :: DBEq a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
80a ==? b = coalesce $ unsafeLiftOpNullable eq a b
104a ==? b = coalesce $ unsafeLiftOpNullable eq a b
81infix 4 ==?
105infix 4 ==?
108+-- | Test if two expressions are different.
110+-- This corresponds to the SQL @<>@ operator, though it will always return a
113+-- >>> select c $ pure $ lit Nothing /=? lit True
116+-- >>> select c $ pure $ lit Nothing /=? lit Nothing
84(/=?) :: DBEq a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
118(/=?) :: DBEq a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
85a /=? b = coalesce $ unsafeLiftOpNullable ne a b
119a /=? b = coalesce $ unsafeLiftOpNullable ne a b
86infix 4 /=?
120infix 4 /=?