module Opaleye.Internal.HaskellDB.Sql where
import qualified Data.List.NonEmpty as NEL
data SqlTable = SqlTable
{ sqlTableSchemaName :: Maybe String
, sqlTableName :: String
} deriving Show
newtype SqlColumn = SqlColumn String deriving Show
type SqlName = String
data SqlOrderNulls = SqlNullsFirst | SqlNullsLast
deriving Show
data SqlOrderDirection = SqlAsc | SqlDesc
deriving Show
data SqlOrder = SqlOrder { sqlOrderDirection :: SqlOrderDirection
, sqlOrderNulls :: SqlOrderNulls }
deriving Show
data SqlExpr = ColumnSqlExpr SqlColumn
| CompositeSqlExpr SqlExpr String
| BinSqlExpr String SqlExpr SqlExpr
| PrefixSqlExpr String SqlExpr
| PostfixSqlExpr String SqlExpr
| FunSqlExpr String [SqlExpr]
| AggrFunSqlExpr String [SqlExpr]
| ConstSqlExpr String
| CaseSqlExpr [(SqlExpr,SqlExpr)] SqlExpr
| ListSqlExpr [SqlExpr]
| ParamSqlExpr (Maybe SqlName) SqlExpr
| PlaceHolderSqlExpr
| ParensSqlExpr SqlExpr
| CastSqlExpr String SqlExpr
| DefaultSqlExpr
deriving Show
data SqlUpdate = SqlUpdate SqlTable [(SqlColumn,SqlExpr)] [SqlExpr]
data SqlDelete = SqlDelete SqlTable [SqlExpr]
data SqlInsert = SqlInsert SqlTable [SqlColumn] (NEL.NonEmpty [SqlExpr])