haskelldb-2.2.2: A library of combinators for generating and executing SQL statements.

Portability | non-portable
Stability | experimental
Maintainer | haskelldb-users@lists.sourceforge.net
Safe Haskell | None

Database.HaskellDB.Sql.Default

Contents

- Utilities

Description

Default SQL generation.

Synopsis

- mkSqlGenerator :: SqlGenerator -> SqlGenerator
- defaultSqlGenerator :: SqlGenerator
- defaultSqlQuery :: SqlGenerator -> PrimQuery -> SqlSelect
- defaultSqlUpdate :: SqlGenerator -> TableName -> [PrimExpr] -> Assoc -> SqlUpdate
- defaultSqlDelete :: SqlGenerator -> TableName -> [PrimExpr] -> SqlDelete
- defaultSqlInsert :: SqlGenerator -> TableName -> Assoc -> SqlInsert
- defaultSqlInsertQuery :: SqlGenerator -> TableName -> PrimQuery -> SqlInsert
- defaultSqlCreateDB :: SqlGenerator -> String -> SqlCreate
- defaultSqlCreateTable :: SqlGenerator -> TableName -> [(Attribute, FieldDesc)] -> SqlCreate
- defaultSqlDropDB :: SqlGenerator -> String -> SqlDrop
- defaultSqlDropTable :: SqlGenerator -> TableName -> SqlDrop
- defaultSqlEmpty :: SqlGenerator -> SqlSelect
- defaultSqlTable :: SqlGenerator -> TableName -> Scheme -> SqlSelect
- defaultSqlProject :: SqlGenerator -> Assoc -> SqlSelect -> SqlSelect
- defaultSqlRestrict :: SqlGenerator -> PrimExpr -> SqlSelect -> SqlSelect
- defaultSqlBinary :: SqlGenerator -> RelOp -> SqlSelect -> SqlSelect -> SqlSelect
- defaultSqlGroup :: SqlGenerator -> Assoc -> SqlSelect -> SqlSelect
- defaultSqlSpecial :: SqlGenerator -> SpecialOp -> SqlSelect -> SqlSelect
- defaultSqlExpr :: SqlGenerator -> PrimExpr -> SqlExpr
- defaultSqlLiteral :: SqlGenerator -> Literal -> String
- defaultSqlType :: SqlGenerator -> FieldType -> SqlType
- defaultSqlQuote :: SqlGenerator -> String -> String
- toSqlSelect :: SqlSelect -> SqlSelect

# Documentation

mkSqlGenerator :: SqlGenerator -> SqlGenerator Source

defaultSqlGenerator :: SqlGenerator Source

defaultSqlQuery :: SqlGenerator -> PrimQuery -> SqlSelect Source

Creates a `SqlSelect` based on the `PrimQuery` supplied. Corresponds to the SQL statement SELECT.

defaultSqlUpdate Source

Arguments

:: SqlGenerator |
-> TableName | Name of the table to update.
-> [PrimExpr] | Conditions which must all be true for a row to be updated.
-> Assoc | Update the data with this.
-> SqlUpdate |

Creates a `SqlUpdate`. Corresponds to the SQL statement UPDATE which updates data in a table.

defaultSqlDelete Source

Arguments

:: SqlGenerator |
-> TableName | Name of the table
-> [PrimExpr] | Criteria which must all be true for a row to be deleted.
-> SqlDelete |

Creates a `SqlDelete`. Corresponds to the SQL statement DELETE which deletes rows in a table.

defaultSqlInsert Source

Arguments

:: SqlGenerator |
-> TableName | Name of the table
-> Assoc | What to insert.
-> SqlInsert |

Creates a `SqlInsert`.

defaultSqlInsertQuery Source

Arguments

:: SqlGenerator |
-> TableName | Name of the table
-> PrimQuery | What to insert
-> SqlInsert |

Creates a `SqlInsert`. Corresponds to the SQL statement INSERT INTO which is used to insert new rows in a table.

defaultSqlCreateDB Source

Arguments

:: SqlGenerator |
-> String | name of the database.
-> SqlCreate |

Use this to create a `SqlCreate` data type corresponding to the SQL statement CREATE DATABASE which creates a new database.

defaultSqlCreateTable Source

Arguments

:: SqlGenerator |
-> TableName | name of the table to be created.
-> [(Attribute, FieldDesc)] | Column descriptions
-> SqlCreate |

Use this to create a `SqlCreate` data type corresponding to the SQL statement CREATE which creates a new table.

defaultSqlDropDB :: SqlGenerator -> String -> SqlDrop Source

Creates a `SqlDrop` that delete the database with the name given as the first argument.

defaultSqlDropTable :: SqlGenerator -> TableName -> SqlDrop Source

Creates a `SqlDrop` that delete the database named in the first argument.

defaultSqlEmpty :: SqlGenerator -> SqlSelect Source

defaultSqlTable :: SqlGenerator -> TableName -> Scheme -> SqlSelect Source

defaultSqlProject :: SqlGenerator -> Assoc -> SqlSelect -> SqlSelect Source

defaultSqlRestrict :: SqlGenerator -> PrimExpr -> SqlSelect -> SqlSelect Source

defaultSqlBinary :: SqlGenerator -> RelOp -> SqlSelect -> SqlSelect -> SqlSelect Source

defaultSqlGroup :: SqlGenerator -> Assoc -> SqlSelect -> SqlSelect Source

Ensures the groupby value on the SqlSelect either preserves existing grouping or that it will group on all columns (i.e, Mark == All).

defaultSqlSpecial :: SqlGenerator -> SpecialOp -> SqlSelect -> SqlSelect Source

defaultSqlExpr :: SqlGenerator -> PrimExpr -> SqlExpr Source

defaultSqlLiteral :: SqlGenerator -> Literal -> String Source

defaultSqlType :: SqlGenerator -> FieldType -> SqlType Source

defaultSqlQuote :: SqlGenerator -> String -> String Source

# Utilities

toSqlSelect :: SqlSelect -> SqlSelect Source

Make sure our SqlSelect statement is really a SqlSelect and not another constructor.