beam-sqlite-0.3.2.1: Beam driver for SQLite

Safe HaskellNone
LanguageHaskell2010

Database.Beam.Sqlite.Syntax

Contents

Description

SQLite implementations of the Beam SQL syntax classes

The SQLite command syntax is implemented by SQLiteCommandSyntax.

Synopsis

SQLite syntaxes

data SqliteSyntax Source #

The syntax for SQLite is stored as a Builder along with a list of data that hasn't been serialized yet.

The first argument is a function that receives a builder for SQLData and returns the concrete syntax to embed into the query. For queries sent to the backend, this is simply a function that returns "?". Thus, the syntax sent to the backend includes proper placeholders. The list of data is sent to the SQLite library for proper escaping.

When the syntax is being serialized for display (for use in beam migrate for example), the data builder attempts to properly format and escape the data. This returns syntax suitable for inclusion in scripts. In this case, the value list is ignored.

Constructors

SqliteSyntax ((SQLData -> Builder) -> Builder) (DList SQLData) 

data SqliteCommandSyntax Source #

A SQLite command. INSERT is special cased to handle AUTO INCREMENT columns. The fromSqliteCommand function will take an SqliteCommandSyntax and convert it into the correct SqliteSyntax.

Instances

IsSql92Syntax SqliteCommandSyntax Source # 
IsSql92DdlCommandSyntax SqliteCommandSyntax Source # 
MonadBeamInsertReturning SqliteCommandSyntax Sqlite Connection SqliteM # 
MonadBeam SqliteCommandSyntax Sqlite Connection SqliteM # 
type Sql92DeleteSyntax SqliteCommandSyntax Source # 
type Sql92UpdateSyntax SqliteCommandSyntax Source # 
type Sql92InsertSyntax SqliteCommandSyntax Source # 
type Sql92SelectSyntax SqliteCommandSyntax Source # 
type Sql92DdlCommandDropTableSyntax SqliteCommandSyntax Source # 
type Sql92DdlCommandAlterTableSyntax SqliteCommandSyntax Source # 
type Sql92DdlCommandCreateTableSyntax SqliteCommandSyntax Source # 

data SqliteColumnSchemaSyntax Source #

SQLite syntax for column schemas in CREATE TABLE or ALTER COLUMN ... ADD COLUMN statements

Instances

Eq SqliteColumnSchemaSyntax Source # 
Show SqliteColumnSchemaSyntax Source # 
Generic SqliteColumnSchemaSyntax Source # 
Hashable SqliteColumnSchemaSyntax Source # 
IsBeamSerialColumnSchemaSyntax SqliteColumnSchemaSyntax Source # 
Sql92DisplaySyntax SqliteColumnSchemaSyntax Source # 
IsSql92ColumnSchemaSyntax SqliteColumnSchemaSyntax Source # 
HasDefaultSqlDataTypeConstraints SqliteColumnSchemaSyntax ByteString Source # 
HasDefaultSqlDataTypeConstraints SqliteColumnSchemaSyntax LocalTime Source # 
HasDefaultSqlDataTypeConstraints SqliteColumnSchemaSyntax (SqlSerial Int) Source # 
type Rep SqliteColumnSchemaSyntax Source # 
type Rep SqliteColumnSchemaSyntax = D1 * (MetaData "SqliteColumnSchemaSyntax" "Database.Beam.Sqlite.Syntax" "beam-sqlite-0.3.2.1-nKBw1z0fW35a5CCkHnLcT" False) (C1 * (MetaCons "SqliteColumnSchemaSyntax" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "fromSqliteColumnSchema") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * SqliteSyntax)) (S1 * (MetaSel (Just Symbol "sqliteIsSerialColumn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Bool))))
type Sql92ColumnSchemaColumnConstraintDefinitionSyntax SqliteColumnSchemaSyntax Source # 
type Sql92ColumnSchemaExpressionSyntax SqliteColumnSchemaSyntax Source # 
type Sql92ColumnSchemaColumnTypeSyntax SqliteColumnSchemaSyntax Source # 

data SqliteExpressionSyntax Source #

Implements beam SQL expression syntaxes

Instances

Eq SqliteExpressionSyntax Source # 
Show SqliteExpressionSyntax Source # 
Generic SqliteExpressionSyntax Source # 
Hashable SqliteExpressionSyntax Source # 
IsCustomSqlSyntax SqliteExpressionSyntax Source # 
IsSql99ConcatExpressionSyntax SqliteExpressionSyntax Source # 
IsSql92ExpressionSyntax SqliteExpressionSyntax Source # 

Methods

valueE :: Sql92ExpressionValueSyntax SqliteExpressionSyntax -> SqliteExpressionSyntax #

rowE :: [SqliteExpressionSyntax] -> SqliteExpressionSyntax #

quantifierListE :: [SqliteExpressionSyntax] -> SqliteExpressionSyntax #

coalesceE :: [SqliteExpressionSyntax] -> SqliteExpressionSyntax #

caseE :: [(SqliteExpressionSyntax, SqliteExpressionSyntax)] -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

fieldE :: Sql92ExpressionFieldNameSyntax SqliteExpressionSyntax -> SqliteExpressionSyntax #

betweenE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

andE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

orE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

addE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

subE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

mulE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

divE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

likeE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

modE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

overlapsE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

nullIfE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

positionE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

eqE :: Maybe (Sql92ExpressionQuantifierSyntax SqliteExpressionSyntax) -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

neqE :: Maybe (Sql92ExpressionQuantifierSyntax SqliteExpressionSyntax) -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

ltE :: Maybe (Sql92ExpressionQuantifierSyntax SqliteExpressionSyntax) -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

gtE :: Maybe (Sql92ExpressionQuantifierSyntax SqliteExpressionSyntax) -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

leE :: Maybe (Sql92ExpressionQuantifierSyntax SqliteExpressionSyntax) -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

geE :: Maybe (Sql92ExpressionQuantifierSyntax SqliteExpressionSyntax) -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

eqMaybeE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

neqMaybeE :: SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

castE :: SqliteExpressionSyntax -> Sql92ExpressionCastTargetSyntax SqliteExpressionSyntax -> SqliteExpressionSyntax #

notE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

negateE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

isNullE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

isNotNullE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

isTrueE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

isNotTrueE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

isFalseE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

isNotFalseE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

isUnknownE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

isNotUnknownE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

charLengthE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

octetLengthE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

bitLengthE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

lowerE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

upperE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

trimE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

absE :: SqliteExpressionSyntax -> SqliteExpressionSyntax #

extractE :: Sql92ExpressionExtractFieldSyntax SqliteExpressionSyntax -> SqliteExpressionSyntax -> SqliteExpressionSyntax #

existsE :: Sql92ExpressionSelectSyntax SqliteExpressionSyntax -> SqliteExpressionSyntax #

uniqueE :: Sql92ExpressionSelectSyntax SqliteExpressionSyntax -> SqliteExpressionSyntax #

subqueryE :: Sql92ExpressionSelectSyntax SqliteExpressionSyntax -> SqliteExpressionSyntax #

currentTimestampE :: SqliteExpressionSyntax #

defaultE :: SqliteExpressionSyntax #

inE :: SqliteExpressionSyntax -> [SqliteExpressionSyntax] -> SqliteExpressionSyntax #

IsSql92AggregationExpressionSyntax SqliteExpressionSyntax Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Bool Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Char Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Double Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Float Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Int Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Int8 Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Int16 Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Int32 Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Int64 Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Integer Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Word Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Word8 Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Word16 Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Word32 Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Word64 Source # 
HasSqlEqualityCheck SqliteExpressionSyntax ByteString Source # 
HasSqlEqualityCheck SqliteExpressionSyntax ByteString Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Scientific Source # 
HasSqlEqualityCheck SqliteExpressionSyntax String Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Text Source # 
HasSqlEqualityCheck SqliteExpressionSyntax UTCTime Source # 
HasSqlEqualityCheck SqliteExpressionSyntax Text Source # 
HasSqlEqualityCheck SqliteExpressionSyntax ZonedTime Source # 
HasSqlEqualityCheck SqliteExpressionSyntax LocalTime Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Bool Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Char Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Double Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Float Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Int Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Int8 Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Int16 Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Int32 Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Int64 Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Integer Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Word Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Word8 Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Word16 Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Word32 Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Word64 Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax ByteString Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax ByteString Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Scientific Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax String Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Text Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax UTCTime Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax Text Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax ZonedTime Source # 
HasSqlQuantifiedEqualityCheck SqliteExpressionSyntax LocalTime Source # 
IsString (CustomSqlSyntax SqliteExpressionSyntax) Source # 
Semigroup (CustomSqlSyntax SqliteExpressionSyntax) Source # 
Monoid (CustomSqlSyntax SqliteExpressionSyntax) Source # 
IsSqlExpressionSyntaxStringType * * SqliteExpressionSyntax String Source # 
IsSqlExpressionSyntaxStringType * * SqliteExpressionSyntax Text Source # 
type Rep SqliteExpressionSyntax Source # 
type Rep SqliteExpressionSyntax = D1 * (MetaData "SqliteExpressionSyntax" "Database.Beam.Sqlite.Syntax" "beam-sqlite-0.3.2.1-nKBw1z0fW35a5CCkHnLcT" False) ((:+:) * (C1 * (MetaCons "SqliteExpressionSyntax" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * SqliteSyntax))) (C1 * (MetaCons "SqliteExpressionDefault" PrefixI False) (U1 *)))
data CustomSqlSyntax SqliteExpressionSyntax Source # 
type Sql92ExpressionExtractFieldSyntax SqliteExpressionSyntax Source # 
type Sql92ExpressionCastTargetSyntax SqliteExpressionSyntax Source # 
type Sql92ExpressionFieldNameSyntax SqliteExpressionSyntax Source # 
type Sql92ExpressionSelectSyntax SqliteExpressionSyntax Source # 
type Sql92ExpressionValueSyntax SqliteExpressionSyntax Source # 
type Sql92ExpressionQuantifierSyntax SqliteExpressionSyntax Source # 
type Sql92AggregationSetQuantifierSyntax SqliteExpressionSyntax Source # 

newtype SqliteValueSyntax Source #

SQLite syntax for values that can be embedded in SqliteSyntax

Instances

HasSqlValueSyntax SqliteValueSyntax Bool Source # 
HasSqlValueSyntax SqliteValueSyntax Double Source # 
HasSqlValueSyntax SqliteValueSyntax Float Source # 
HasSqlValueSyntax SqliteValueSyntax Int Source # 
HasSqlValueSyntax SqliteValueSyntax Int8 Source # 
HasSqlValueSyntax SqliteValueSyntax Int16 Source # 
HasSqlValueSyntax SqliteValueSyntax Int32 Source # 
HasSqlValueSyntax SqliteValueSyntax Int64 Source # 
HasSqlValueSyntax SqliteValueSyntax Word Source # 
HasSqlValueSyntax SqliteValueSyntax Word8 Source # 
HasSqlValueSyntax SqliteValueSyntax Word16 Source # 
HasSqlValueSyntax SqliteValueSyntax Word32 Source # 
HasSqlValueSyntax SqliteValueSyntax Word64 Source # 
HasSqlValueSyntax SqliteValueSyntax ByteString Source # 
HasSqlValueSyntax SqliteValueSyntax Scientific Source # 
HasSqlValueSyntax SqliteValueSyntax String Source # 
HasSqlValueSyntax SqliteValueSyntax Text Source # 
HasSqlValueSyntax SqliteValueSyntax Text Source # 
HasSqlValueSyntax SqliteValueSyntax SqlNull Source # 
HasSqlValueSyntax SqliteValueSyntax LocalTime Source # 
HasSqlValueSyntax SqliteValueSyntax Day Source # 
HasSqlValueSyntax SqliteValueSyntax x => HasSqlValueSyntax SqliteValueSyntax (Maybe x) Source # 

SQLite data type syntax

data SqliteDataTypeSyntax Source #

SQLite syntax that implements IsSql92DataTypeSyntax and a good portion of IsSql99DataTypeSyntax, except for array and row types.

Instances

Eq SqliteDataTypeSyntax Source # 
Show SqliteDataTypeSyntax Source # 
Generic SqliteDataTypeSyntax Source # 
Hashable SqliteDataTypeSyntax Source # 
IsSql2008BigIntDataTypeSyntax SqliteDataTypeSyntax Source # 
IsSql99DataTypeSyntax SqliteDataTypeSyntax Source # 
IsSql92DataTypeSyntax SqliteDataTypeSyntax Source # 
Sql92DisplaySyntax SqliteDataTypeSyntax Source # 
Sql92SerializableDataTypeSyntax SqliteDataTypeSyntax Source # 
HasDefaultSqlDataType SqliteDataTypeSyntax ByteString Source # 
HasDefaultSqlDataType SqliteDataTypeSyntax LocalTime Source # 
HasDefaultSqlDataType SqliteDataTypeSyntax (SqlSerial Int) Source # 
type Rep SqliteDataTypeSyntax Source # 
type Rep SqliteDataTypeSyntax = D1 * (MetaData "SqliteDataTypeSyntax" "Database.Beam.Sqlite.Syntax" "beam-sqlite-0.3.2.1-nKBw1z0fW35a5CCkHnLcT" False) (C1 * (MetaCons "SqliteDataTypeSyntax" PrefixI True) ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "fromSqliteDataType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * SqliteSyntax)) (S1 * (MetaSel (Just Symbol "sqliteDataTypeToHs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * HsDataType))) ((:*:) * (S1 * (MetaSel (Just Symbol "sqliteDataTypeSerialized") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * BeamSerializedDataType)) (S1 * (MetaSel (Just Symbol "sqliteDataTypeSerial") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Bool)))))

Building and consuming SqliteSyntax

formatSqliteInsert :: Text -> [Text] -> SqliteInsertValuesSyntax -> SqliteSyntax Source #

Format a SQLite INSERT expression for the given table name, fields, and values.

emit :: ByteString -> SqliteSyntax Source #

Embed a ByteString directly in the syntax

emitValue :: SQLData -> SqliteSyntax Source #

Emit a properly escaped value into the syntax

This causes a literal ? 3

sqliteEscape :: Text -> Text Source #

A best effort attempt to implement the escaping rules of SQLite. This is never used to escape data sent to the database; only for emitting scripts or displaying syntax to the user.

withPlaceholders :: ((SQLData -> Builder) -> Builder) -> Builder Source #

Convert the first argument of SQLiteSyntax to a ByteString Builder, where all the data has been replaced by "?" placeholders.

sqliteRenderSyntaxScript :: SqliteSyntax -> ByteString Source #

Render a SqliteSyntax as a lazy ByteString, for purposes of displaying to a user. Embedded SQLData is directly embedded into the concrete syntax, with a best effort made to escape strings.