{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
-- | Do not use.  Will be deprecated in version 0.10.  Use
-- "Opaleye.Field" instead.
--
-- Functions for working directly with 'Column's.
--
-- Please note that numeric 'Column' types are instances of 'Num', so
-- you can use '*', '/', '+', '-' on them.

module Opaleye.Column (-- * 'Column'
                       Column,
                       -- * Working with @NULL@
                       Nullable,
                       null,
                       isNull,
                       -- * Unsafe operations
                       unsafeCast,
                       unsafeCoerceColumn,
                       unsafeCompositeField,
                       -- * Entire module
                       module Opaleye.Column)  where

import           Opaleye.Internal.Column (Column, Nullable, unsafeCoerceColumn,
                                          unsafeCast, unsafeCompositeField)
import qualified Opaleye.Field as F
import qualified Opaleye.Internal.Column as C
import qualified Opaleye.Internal.HaskellDB.PrimQuery as HPQ
import qualified Opaleye.Internal.PGTypesExternal as T
import           Prelude hiding (null)

-- | A NULL of any type
null :: Column (Nullable a)
null :: Column (Nullable a)
null = Column (Nullable a)
forall a. FieldNullable a
F.null

-- | @TRUE@ if the value of the column is @NULL@, @FALSE@ otherwise.
isNull :: Column (Nullable a) -> Column T.PGBool
isNull :: Column (Nullable a) -> Column PGBool
isNull = UnOp -> Field_ 'Nullable a -> Field_ 'NonNullable PGBool
forall (n :: Nullability) a (n' :: Nullability) b.
UnOp -> Field_ n a -> Field_ n' b
C.unOp UnOp
HPQ.OpIsNull

joinNullable :: Column (Nullable (Nullable a)) -> Column (Nullable a)
joinNullable :: Column (Nullable (Nullable a)) -> Column (Nullable a)
joinNullable = Column (Nullable (Nullable a)) -> Column (Nullable a)
forall (n :: Nullability) a (n' :: Nullability) b.
Field_ n a -> Field_ n' b
unsafeCoerceColumn