module Opaleye.Internal.HaskellDB.PrimQuery where
import qualified Opaleye.Internal.Tag as T
import Data.ByteString (ByteString)
import qualified Data.List.NonEmpty as NEL
type TableName = String
type Attribute = String
type Name = String
type Scheme = [Attribute]
type Assoc = [(Attribute,PrimExpr)]
data Symbol = Symbol String T.Tag deriving (Read, Show)
data PrimExpr = AttrExpr Symbol
| BaseTableAttrExpr Attribute
| CompositeExpr PrimExpr Attribute
| BinExpr BinOp PrimExpr PrimExpr
| UnExpr UnOp PrimExpr
| AggrExpr AggrOp PrimExpr [OrderExpr]
| ConstExpr Literal
| CaseExpr [(PrimExpr,PrimExpr)] PrimExpr
| ListExpr (NEL.NonEmpty PrimExpr)
| ParamExpr (Maybe Name) PrimExpr
| FunExpr Name [PrimExpr]
| CastExpr Name PrimExpr
| DefaultInsertExpr
| ArrayExpr [PrimExpr]
deriving (Read,Show)
data Literal = NullLit
| DefaultLit
| BoolLit Bool
| StringLit String
| ByteStringLit ByteString
| IntegerLit Integer
| DoubleLit Double
| OtherLit String
deriving (Read,Show)
data BinOp = (:==) | (:<) | (:<=) | (:>) | (:>=) | (:<>)
| OpAnd | OpOr
| OpLike | OpILike | OpIn
| OpOther String
| (:||)
| (:+) | (:-) | (:*) | (:/) | OpMod
| (:~) | (:&) | (:|) | (:^)
| (:=) | OpAtTimeZone
| (:->) | (:->>) | (:#>) | (:#>>)
| (:@>) | (:<@) | (:?) | (:?|) | (:?&)
deriving (Show,Read)
data UnOp = OpNot
| OpIsNull
| OpIsNotNull
| OpLength
| OpAbs
| OpNegate
| OpLower
| OpUpper
| UnOpOther String
deriving (Show,Read)
data AggrOp = AggrCount | AggrSum | AggrAvg | AggrMin | AggrMax
| AggrStdDev | AggrStdDevP | AggrVar | AggrVarP
| AggrBoolOr | AggrBoolAnd | AggrArr | AggrStringAggr PrimExpr
| AggrOther String
deriving (Show,Read)
data OrderExpr = OrderExpr OrderOp PrimExpr
deriving (Show,Read)
data OrderNulls = NullsFirst | NullsLast
deriving (Show,Read)
data OrderDirection = OpAsc | OpDesc
deriving (Show,Read)
data OrderOp = OrderOp { orderDirection :: OrderDirection
, orderNulls :: OrderNulls }
deriving (Show,Read)