sqlite-0.4.2: Haskell binding to sqlite3Source codeContentsIndex
Database.SQL.Types
PortabilityBasic embedding of SQL types in Haskell.
Stabilityprovisional
MaintainerDon Stewart <dons@galois.com>
Description
Note: the quary part of this modules was imported (with modifications) from the lowest layer of abstraction of HaskellDB.
Synopsis
type TableName = String
type ColumnName = String
type DatabaseName = String
type OpName = String
data SQLOrder
= SQLAsc
| SQLDesc
data SQLSelect
= SQLSelect {
options :: [String]
attrs :: [(SQLExpr, String)]
tables :: SelectSource
criteria :: [SQLExpr]
groupby :: [SQLExpr]
orderby :: [(SQLExpr, SQLOrder)]
extra :: [String]
}
| SQLBin OpName SQLSelect SQLSelect
select_all :: SelectSource -> SQLSelect
data SelectSource = From TableSource [Join]
data Join = Join OpName TableSource (Maybe (OpName, SQLExpr))
data TableSource
= SrcTable TableName String
| SrcSelect SQLSelect String
data SQLExpr
= ColumnSQLExpr ColumnName
| BinSQLExpr OpName SQLExpr SQLExpr
| PrefixSQLExpr OpName SQLExpr
| PostfixSQLExpr OpName SQLExpr
| FunSQLExpr OpName [SQLExpr]
| ConstSQLExpr String
| CaseSQLExpr [(SQLExpr, SQLExpr)] SQLExpr
| ListSQLExpr [SQLExpr]
data SQLUpdate = SQLUpdate TableName [(ColumnName, SQLExpr)] [SQLExpr]
data SQLDelete = SQLDelete TableName [SQLExpr]
data SQLInsert
= SQLInsert TableName [ColumnName] [SQLExpr]
| SQLInsertQuery TableName [ColumnName] SQLSelect
data SQLCreate a
= SQLCreateDB DatabaseName
| SQLCreateTable (Table a)
data SQLDrop
= SQLDropDB DatabaseName
| SQLDropTable TableName
data Clause
= IsNullable Bool
| DefaultValue String
| PrimaryKey Bool
| ForeignKey TableName [ColumnName]
| Clustered Bool
| Unique
data Constraint
= TablePrimaryKey [ColumnName]
| TableUnique [ColumnName]
| TableCheck SQLExpr
data Table a
= Table {
tabName :: String
tabColumns :: [Column a]
tabConstraints :: [Constraint]
}
| VirtualTable {
tabName :: String
tabColumns :: [Column a]
tabConstraints :: [Constraint]
tabUsing :: String
}
data Column a = Column {
colName :: ColumnName
colType :: a
colClauses :: [Clause]
}
type SQLTable = Table SQLType
data SQLType
= SQLBoolean
| SQLChar (Maybe Int)
| SQLVarChar Int
| SQLBlob BlobType
| SQLDateTime DateTimeType
| SQLInt IntType Bool Bool
| SQLDecimal (Maybe Int) (Maybe Int)
| SQLFloat (Maybe Int) (Maybe Int)
| SQLEnum [String]
| SQLSet [String]
data IntType
= TINY
| SMALL
| MEDIUM
| NORMAL
| BIG
data DateTimeType
= DATE
| DATETIME
| TIMESTAMP
| TIME
| YEAR (Maybe Int)
data BlobType
= TinyBlob
| NormalBlob (Maybe Int)
| MediumBlob
| LongBlob
showType :: SQLType -> String
showClause :: Clause -> String
toSQLString :: String -> String
export_sql :: PrettySQL t => t -> String
class PrettySQL t where
pp_sql :: t -> Doc
Documentation
type TableName = StringSource
type ColumnName = StringSource
type DatabaseName = StringSource
type OpName = StringSource
data SQLOrder Source
Constructors
SQLAsc
SQLDesc
data SQLSelect Source
Data type for SQL SELECT statements.
Constructors
SQLSelect
options :: [String]DISTINCT, ALL etc. | result, alias. Empty list means select all.
attrs :: [(SQLExpr, String)]
tables :: SelectSourceFROM
criteria :: [SQLExpr]WHERE
groupby :: [SQLExpr]GROUP BY
orderby :: [(SQLExpr, SQLOrder)]ORDER BY
extra :: [String]TOP n, etc.
SQLBin OpName SQLSelect SQLSelectUNION, etc
show/hide Instances
select_all :: SelectSource -> SQLSelectSource
data SelectSource Source
Constructors
From TableSource [Join]
data Join Source
Join with another table.
Constructors
Join OpName TableSource (Maybe (OpName, SQLExpr))
data TableSource Source
Use empty string for no alias.
Constructors
SrcTable TableName String
SrcSelect SQLSelect String
data SQLExpr Source
Expressions in SQL statements.
Constructors
ColumnSQLExpr ColumnName
BinSQLExpr OpName SQLExpr SQLExpr
PrefixSQLExpr OpName SQLExpr
PostfixSQLExpr OpName SQLExpr
FunSQLExpr OpName [SQLExpr]
ConstSQLExpr String
CaseSQLExpr [(SQLExpr, SQLExpr)] SQLExpr
ListSQLExpr [SQLExpr]
data SQLUpdate Source
Data type for SQL UPDATE statements.
Constructors
SQLUpdate TableName [(ColumnName, SQLExpr)] [SQLExpr]
show/hide Instances
data SQLDelete Source
Data type for SQL DELETE statements.
Constructors
SQLDelete TableName [SQLExpr]
show/hide Instances
data SQLInsert Source
Data type for SQL INSERT statements.
Constructors
SQLInsert TableName [ColumnName] [SQLExpr]
SQLInsertQuery TableName [ColumnName] SQLSelect
show/hide Instances
data SQLCreate a Source
Data type for SQL CREATE statements.
Constructors
SQLCreateDB DatabaseNameCreate a database
SQLCreateTable (Table a)Create a table
show/hide Instances
data SQLDrop Source
Data type representing the SQL DROP statement.
Constructors
SQLDropDB DatabaseNameDelete a database
SQLDropTable TableNameDelete a table named SQLTable
show/hide Instances
data Clause Source
Constructors
IsNullable Bool
DefaultValue String
PrimaryKey BoolAuto-increment?
ForeignKey TableName [ColumnName]
Clustered Bool
Unique
data Constraint Source
Constructors
TablePrimaryKey [ColumnName]
TableUnique [ColumnName]
TableCheck SQLExpr
data Table a Source
Constructors
Table
tabName :: String
tabColumns :: [Column a]
tabConstraints :: [Constraint]
VirtualTable
tabName :: String
tabColumns :: [Column a]
tabConstraints :: [Constraint]
tabUsing :: String
data Column a Source
We parameterize over column type, since SQL engines do tend to provide their own set of supported datatypes (which may or may not map onto SQL99's set of types.)
Constructors
Column
colName :: ColumnName
colType :: a
colClauses :: [Clause]
type SQLTable = Table SQLTypeSource
data SQLType Source
MySQL slanted, but also SQLite friendly if you don't get too fancy..
Constructors
SQLBoolean
SQLChar (Maybe Int)
SQLVarChar Int
SQLBlob BlobType
SQLDateTime DateTimeType
SQLInt IntType Bool Bool
SQLDecimal (Maybe Int) (Maybe Int)
SQLFloat (Maybe Int) (Maybe Int)
SQLEnum [String]
SQLSet [String]
show/hide Instances
data IntType Source
Constructors
TINY
SMALL
MEDIUM
NORMAL
BIG
data DateTimeType Source
Constructors
DATE
DATETIME
TIMESTAMP
TIME
YEAR (Maybe Int)
data BlobType Source
Constructors
TinyBlob
NormalBlob (Maybe Int)
MediumBlob
LongBlob
showType :: SQLType -> StringSource
showClause :: Clause -> StringSource
toSQLString :: String -> StringSource
export_sql :: PrettySQL t => t -> StringSource
class PrettySQL t whereSource
Methods
pp_sql :: t -> DocSource
show/hide Instances
Produced by Haddock version 2.4.2