Safe Haskell | None |
---|---|
Language | Haskell2010 |
Database.Beam.Sqlite.Syntax
Description
SQLite implementations of the Beam SQL syntax classes
The SQLite command syntax is implemented by
SQLiteCommandSyntax
.
Synopsis
- data SqliteSyntax = SqliteSyntax (( SQLData -> Builder ) -> Builder ) ( DList SQLData )
- data SqliteCommandSyntax
- newtype SqliteSelectSyntax = SqliteSelectSyntax { }
- data SqliteInsertSyntax = SqliteInsertSyntax { }
- newtype SqliteUpdateSyntax = SqliteUpdateSyntax { }
- newtype SqliteDeleteSyntax = SqliteDeleteSyntax { }
- newtype SqliteOnConflictSyntax = SqliteOnConflictSyntax { }
- data SqliteInsertValuesSyntax
- data SqliteColumnSchemaSyntax = SqliteColumnSchemaSyntax { }
- data SqliteExpressionSyntax
- newtype SqliteValueSyntax = SqliteValueSyntax { }
- newtype SqliteTableNameSyntax = SqliteTableNameSyntax { }
- newtype SqliteFieldNameSyntax = SqliteFieldNameSyntax { }
- newtype SqliteAggregationSetQuantifierSyntax = SqliteAggregationSetQuantifierSyntax { }
- fromSqliteExpression :: SqliteExpressionSyntax -> SqliteSyntax
- data SqliteDataTypeSyntax = SqliteDataTypeSyntax { }
- sqliteTextType :: SqliteDataTypeSyntax
- sqliteBlobType :: SqliteDataTypeSyntax
- sqliteBigIntType :: SqliteDataTypeSyntax
- sqliteSerialType :: SqliteDataTypeSyntax
- fromSqliteCommand :: SqliteCommandSyntax -> SqliteSyntax
- formatSqliteInsert :: SqliteTableNameSyntax -> [ Text ] -> SqliteInsertValuesSyntax -> SqliteSyntax
- formatSqliteInsertOnConflict :: SqliteTableNameSyntax -> [ Text ] -> SqliteInsertValuesSyntax -> Maybe SqliteOnConflictSyntax -> SqliteSyntax
- emit :: ByteString -> SqliteSyntax
- emitValue :: SQLData -> SqliteSyntax
- parens :: SqliteSyntax -> SqliteSyntax
- commas :: [ SqliteSyntax ] -> SqliteSyntax
- quotedIdentifier :: Text -> SqliteSyntax
- sqliteEscape :: Text -> Text
- withPlaceholders :: (( SQLData -> Builder ) -> Builder ) -> Builder
- sqliteRenderSyntaxScript :: SqliteSyntax -> ByteString
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.
Instances
Eq SqliteSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax Methods (==) :: SqliteSyntax -> SqliteSyntax -> Bool Source # (/=) :: SqliteSyntax -> SqliteSyntax -> Bool Source # |
|
Show SqliteSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax |
|
Semigroup SqliteSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax Methods (<>) :: SqliteSyntax -> SqliteSyntax -> SqliteSyntax Source # sconcat :: NonEmpty SqliteSyntax -> SqliteSyntax Source # stimes :: Integral b => b -> SqliteSyntax -> SqliteSyntax Source # |
|
Monoid SqliteSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax Methods mempty :: SqliteSyntax Source # mappend :: SqliteSyntax -> SqliteSyntax -> SqliteSyntax Source # mconcat :: [ SqliteSyntax ] -> SqliteSyntax Source # |
|
Hashable SqliteSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax |
|
Sql92DisplaySyntax SqliteSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax Methods displaySyntax :: SqliteSyntax -> String Source # |
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
newtype SqliteSelectSyntax Source #
SQLite
SELECT
syntax
Constructors
SqliteSelectSyntax | |
Fields |
Instances
IsSql92SelectSyntax SqliteSelectSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax Associated Types type Sql92SelectSelectTableSyntax SqliteSelectSyntax Source # Methods selectStmt :: Sql92SelectSelectTableSyntax SqliteSelectSyntax -> [ Sql92SelectOrderingSyntax SqliteSelectSyntax ] -> Maybe Integer -> Maybe Integer -> SqliteSelectSyntax Source # |
|
type Sql92SelectOrderingSyntax SqliteSelectSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax |
|
type Sql92SelectSelectTableSyntax SqliteSelectSyntax Source # | |
data SqliteInsertSyntax Source #
SQLite
INSERT
syntax. This doesn't directly wrap
SqliteSyntax
because
we need to do some processing on
INSERT
statements to deal with
AUTO
INCREMENT
columns. Use
formatSqliteInsert
to turn
SqliteInsertSyntax
into
SqliteSyntax
.
Constructors
SqliteInsertSyntax | |
Fields |
Instances
IsSql92InsertSyntax SqliteInsertSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax Associated Types Methods insertStmt :: Sql92InsertTableNameSyntax SqliteInsertSyntax -> [ Text ] -> Sql92InsertValuesSyntax SqliteInsertSyntax -> SqliteInsertSyntax Source # |
|
type Sql92InsertTableNameSyntax SqliteInsertSyntax Source # | |
type Sql92InsertValuesSyntax SqliteInsertSyntax Source # | |
newtype SqliteUpdateSyntax Source #
SQLite
UPDATE
syntax
Constructors
SqliteUpdateSyntax | |
Fields |
Instances
newtype SqliteDeleteSyntax Source #
SQLite
DELETE
syntax
Constructors
SqliteDeleteSyntax | |
Fields |
Instances
newtype SqliteOnConflictSyntax Source #
SQLite
ON CONFLICT
syntax
Constructors
SqliteOnConflictSyntax | |
Fields |
data SqliteInsertValuesSyntax Source #
SQLite
VALUES
clause in
INSERT
. Expressions need to be handled
explicitly in order to deal with
DEFAULT
values and
AUTO INCREMENT
columns.
Constructors
SqliteInsertExpressions [[ SqliteExpressionSyntax ]] | |
SqliteInsertFromSql SqliteSelectSyntax |
Instances
data SqliteColumnSchemaSyntax Source #
SQLite syntax for column schemas in
CREATE TABLE
or
ALTER COLUMN ... ADD
COLUMN
statements
Constructors
SqliteColumnSchemaSyntax | |
Fields |
Instances
data SqliteExpressionSyntax Source #
Implements beam SQL expression syntaxes
Constructors
SqliteExpressionSyntax SqliteSyntax | |
SqliteExpressionDefault |
Instances
newtype SqliteValueSyntax Source #
SQLite syntax for values that can be embedded in
SqliteSyntax
Constructors
SqliteValueSyntax | |
Fields |
Instances
newtype SqliteTableNameSyntax Source #
Constructors
SqliteTableNameSyntax | |
Fields |
Instances
newtype SqliteFieldNameSyntax Source #
Constructors
SqliteFieldNameSyntax | |
Fields |
Instances
IsSql92FieldNameSyntax SqliteFieldNameSyntax Source # | |
Defined in Database.Beam.Sqlite.Syntax Methods qualifiedField :: Text -> Text -> SqliteFieldNameSyntax Source # |
newtype SqliteAggregationSetQuantifierSyntax Source #
Constructors
SqliteAggregationSetQuantifierSyntax | |
SQLite data type syntax
data SqliteDataTypeSyntax Source #
SQLite syntax that implements
IsSql92DataTypeSyntax
and a good portion of
IsSql99DataTypeSyntax
, except for array and row types.
Constructors
SqliteDataTypeSyntax | |
Instances
Building and consuming
SqliteSyntax
fromSqliteCommand :: SqliteCommandSyntax -> SqliteSyntax Source #
Convert a
SqliteCommandSyntax
into a renderable
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
parens :: SqliteSyntax -> SqliteSyntax Source #
commas :: [ SqliteSyntax ] -> SqliteSyntax Source #
quotedIdentifier :: Text -> SqliteSyntax Source #
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.