| Copyright | (c) Galois Inc. 2007 (c) figo GmbH 2016 |
|---|---|
| License | BSD3 |
| Maintainer | figo GmbH <package+haskell@figo.io> |
| Stability | provisional |
| Portability | Basic embedding of SQL types in Haskell. |
| Safe Haskell | None |
| Language | Haskell98 |
Database.SQL.Types
Description
Note: the quary part of this modules was imported (with modifications) from the lowest layer of abstraction of HaskellDB.
- type TableName = String
- type ColumnName = String
- type DatabaseName = String
- type OpName = String
- data SQLOrder
- data SQLSelect
- select_all :: SelectSource -> SQLSelect
- data SelectSource = From TableSource [Join]
- data Join = Join OpName TableSource (Maybe (OpName, SQLExpr))
- data TableSource
- data SQLExpr
- data SQLUpdate = SQLUpdate TableName [(ColumnName, SQLExpr)] [SQLExpr]
- data SQLDelete = SQLDelete TableName [SQLExpr]
- data SQLInsert
- data SQLCreate a
- data SQLDrop
- data Clause
- data ForeignUpdateCondition
- data ForeignUpdateAction
- = SetNull
- | SetDefault
- | Cascade
- | Restrict
- | NoAction
- data Deferment
- data Constraint
- data Table a
- = Table {
- tabName :: String
- tabColumns :: [Column a]
- tabConstraints :: [Constraint]
- | VirtualTable {
- tabName :: String
- tabColumns :: [Column a]
- tabConstraints :: [Constraint]
- tabUsing :: String
- = Table {
- 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)
- data IntType
- data DateTimeType
- 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
Documentation
type ColumnName = String Source #
type DatabaseName = String Source #
Data type for SQL SELECT statements.
select_all :: SelectSource -> SQLSelect Source #
data SelectSource Source #
Constructors
| From TableSource [Join] |
Join with another table.
data TableSource Source #
Use empty string for no alias.
Expressions in SQL statements.
Data type for SQL UPDATE statements.
Constructors
| SQLUpdate TableName [(ColumnName, SQLExpr)] [SQLExpr] |
Data type for SQL DELETE statements.
Data type for SQL INSERT statements.
Constructors
| SQLInsert TableName [ColumnName] [SQLExpr] | |
| SQLInsertQuery TableName [ColumnName] SQLSelect |
Data type for SQL CREATE statements.
Constructors
| SQLCreateDB DatabaseName | Create a database |
| SQLCreateTable (Table a) | Create a table |
Data type representing the SQL DROP statement.
Constructors
| SQLDropDB DatabaseName | Delete a database |
| SQLDropTable TableName | Delete a table named SQLTable |
Constructors
| IsNullable Bool | |
| DefaultValue String | |
| PrimaryKey Bool | Auto-increment? |
| ForeignKey TableName [ColumnName] [ForeignUpdateCondition] (Maybe Deferment) | |
| Clustered Bool | |
| Unique |
data ForeignUpdateCondition Source #
Constructors
| OnDelete ForeignUpdateAction | |
| OnUpdate ForeignUpdateAction | |
| Match String |
data ForeignUpdateAction Source #
Constructors
| SetNull | |
| SetDefault | |
| Cascade | |
| Restrict | |
| NoAction |
data Constraint Source #
Constructors
| TablePrimaryKey [ColumnName] | |
| TableUnique [ColumnName] | |
| TableCheck SQLExpr |
Constructors
| Table | |
Fields
| |
| VirtualTable | |
Fields
| |
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 | |
Fields
| |
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) |
Constructors
| TinyBlob | |
| NormalBlob (Maybe Int) | |
| MediumBlob | |
| LongBlob |
showClause :: Clause -> String Source #
toSQLString :: String -> String Source #
export_sql :: PrettySQL t => t -> String Source #