beam-sqlite-0.5.0.0: 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 # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsSql92DdlCommandSyntax SqliteCommandSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92DeleteSyntax SqliteCommandSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92UpdateSyntax SqliteCommandSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92InsertSyntax SqliteCommandSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92SelectSyntax SqliteCommandSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92DdlCommandDropTableSyntax SqliteCommandSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92DdlCommandAlterTableSyntax SqliteCommandSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92DdlCommandCreateTableSyntax SqliteCommandSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

newtype SqliteOnConflictSyntax Source #

SQLite ON CONFLICT syntax

data SqliteColumnSchemaSyntax Source #

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

Instances
Eq SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Show SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Generic SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Associated Types

type Rep SqliteColumnSchemaSyntax :: Type -> Type #

Hashable SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Sql92DisplaySyntax SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsSql92ColumnSchemaSyntax SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Rep SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Rep SqliteColumnSchemaSyntax = D1 (MetaData "SqliteColumnSchemaSyntax" "Database.Beam.Sqlite.Syntax" "beam-sqlite-0.5.0.0-ARiIkDkfBRT67kWd6dG4iv" False) (C1 (MetaCons "SqliteColumnSchemaSyntax" PrefixI True) (S1 (MetaSel (Just "fromSqliteColumnSchema") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 SqliteSyntax) :*: S1 (MetaSel (Just "sqliteIsSerialColumn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))
type Sql92ColumnSchemaColumnConstraintDefinitionSyntax SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92ColumnSchemaExpressionSyntax SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92ColumnSchemaColumnTypeSyntax SqliteColumnSchemaSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

data SqliteExpressionSyntax Source #

Implements beam SQL expression syntaxes

Instances
Eq SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Show SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Generic SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Associated Types

type Rep SqliteExpressionSyntax :: Type -> Type #

Hashable SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsCustomSqlSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsSql99FunctionExpressionSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsSql99ConcatExpressionSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsSql92ExpressionSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

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 # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsString (CustomSqlSyntax SqliteExpressionSyntax) Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Semigroup (CustomSqlSyntax SqliteExpressionSyntax) Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Monoid (CustomSqlSyntax SqliteExpressionSyntax) Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Rep SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Rep SqliteExpressionSyntax = D1 (MetaData "SqliteExpressionSyntax" "Database.Beam.Sqlite.Syntax" "beam-sqlite-0.5.0.0-ARiIkDkfBRT67kWd6dG4iv" False) (C1 (MetaCons "SqliteExpressionSyntax" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 SqliteSyntax)) :+: C1 (MetaCons "SqliteExpressionDefault" PrefixI False) (U1 :: Type -> Type))
newtype CustomSqlSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92ExpressionExtractFieldSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92ExpressionCastTargetSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92ExpressionFieldNameSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92ExpressionSelectSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92ExpressionValueSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92ExpressionQuantifierSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Sql92AggregationSetQuantifierSyntax SqliteExpressionSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

newtype SqliteValueSyntax Source #

SQLite syntax for values that can be embedded in SqliteSyntax

Instances
HasSqlValueSyntax SqliteValueSyntax Bool Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Double Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Float Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

(TypeError (PreferExplicitSize Int Int32) :: Constraint) => HasSqlValueSyntax SqliteValueSyntax Int Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Int8 Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Int16 Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Int32 Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Int64 Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

(TypeError (PreferExplicitSize Word Word32) :: Constraint) => HasSqlValueSyntax SqliteValueSyntax Word Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Word8 Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Word16 Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Word32 Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Word64 Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax ByteString Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Scientific Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Text Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax UTCTime Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Text Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax String Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax SqlNull Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax LocalTime Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax Day Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasSqlValueSyntax SqliteValueSyntax x => HasSqlValueSyntax SqliteValueSyntax (Maybe x) Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

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 # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Show SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Generic SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Associated Types

type Rep SqliteDataTypeSyntax :: Type -> Type #

Hashable SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsSql2008BigIntDataTypeSyntax SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsSql99DataTypeSyntax SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Sql92DisplaySyntax SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

IsSql92DataTypeSyntax SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

HasDataTypeCreatedCheck SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

Methods

dataTypeHasBeenCreated :: SqliteDataTypeSyntax -> (forall preCondition. Typeable preCondition => [preCondition]) -> Bool #

Sql92SerializableDataTypeSyntax SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Rep SqliteDataTypeSyntax Source # 
Instance details

Defined in Database.Beam.Sqlite.Syntax

type Rep SqliteDataTypeSyntax = D1 (MetaData "SqliteDataTypeSyntax" "Database.Beam.Sqlite.Syntax" "beam-sqlite-0.5.0.0-ARiIkDkfBRT67kWd6dG4iv" False) (C1 (MetaCons "SqliteDataTypeSyntax" PrefixI True) ((S1 (MetaSel (Just "fromSqliteDataType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 SqliteSyntax) :*: S1 (MetaSel (Just "sqliteDataTypeToHs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 HsDataType)) :*: (S1 (MetaSel (Just "sqliteDataTypeSerialized") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 BeamSerializedDataType) :*: S1 (MetaSel (Just "sqliteDataTypeSerial") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))))

Building and consuming SqliteSyntax

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

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

formatSqliteInsertOnConflict :: SqliteTableNameSyntax -> [Text] -> SqliteInsertValuesSyntax -> Maybe SqliteOnConflictSyntax -> SqliteSyntax Source #

Format a SQLite INSERT expression for the given table name, fields, values, and optionally an ON CONFLICT clause.

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.