{- |
   Module     : Database.SQLDeps.Types
   Copyright  : Copyright (C) 2013 Alexander Thiemann
   License    : BSD3

   Maintainer : Alexander Thiemann <mail@agrafix.net>
   Stability  : provisional
   Portability: portable

Simple type definitions for SQLDeps
-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE DeriveGeneric #-}
module Database.SQLDeps.Types where

import GHC.Generics
import Data.Hashable

type FieldName = (TableName, String)
type TableName = String

data FieldVal
   = IntVal Int
   | StrVal String
   deriving (Eq, Ord, Generic, Show)

data Select
   = Select [FieldName] [TableName] [Filter]
    deriving (Eq, Ord, Generic, Show)

data Upsert
    = Update TableName [(FieldName, FieldVal)] [Filter]
    | Insert TableName [(FieldName, FieldVal)]
    deriving (Eq, Ord, Generic, Show)

data Filter
    = LargerThan FieldName FieldVal
    | SmallerThan FieldName FieldVal
    | EqualTo FieldName FieldVal
    deriving (Eq, Ord, Generic, Show)

instance Hashable Select
instance Hashable FieldVal
instance Hashable Upsert
instance Hashable Filter