postgresql-simple-0.7.0.1: Mid-Level PostgreSQL client library

Copyright | (c) 2011 MailRank Inc. (c) 2011-2012 Leon P Smith
License | BSD3
Maintainer | Leon P Smith <leon@melding-monads.com>
Stability | experimental
Safe Haskell | None
Language | Haskell2010

Database.PostgreSQL.Simple.ToField

Description

The `ToField` typeclass, for rendering a parameter to a SQL query.

Synopsis

- data Action
  - = Plain Builder
  - | Escape ByteString
  - | EscapeByteA ByteString
  - | EscapeIdentifier ByteString
  - | Many [Action]
- class ToField a where
  - toField :: a -> Action
- toJSONField :: ToJSON a => a -> Action
- inQuotes :: Builder -> Builder

# Documentation

data Action Source #

How to render an element when substituting it into a query.

Constructors

Plain Builder | Render without escaping or quoting. Use for non-text types such as numbers, when you are certain that they will not introduce formatting vulnerabilities via use of characters such as spaces or "`'`".
Escape ByteString | Escape and enclose in quotes before substituting. Use for all text-like types, and anything else that may contain unsafe characters when rendered.
EscapeByteA ByteString | Escape binary data for use as a `bytea` literal. Include surrounding quotes. This is used by the `Binary` newtype wrapper.
EscapeIdentifier ByteString | Escape before substituting. Use for all sql identifiers like table, column names, etc. This is used by the `Identifier` newtype wrapper.
Many [Action] | Concatenate a series of rendering actions.

#### Instances

Instances details

Show Action Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods showsPrec :: Int -> Action -> ShowS Source # show :: Action -> String Source # showList :: [Action] -> ShowS Source #
ToField Action Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Action -> Action Source #

class ToField a where Source #

A type that may be used as a single parameter to a SQL query.

Methods

toField :: a -> Action Source #

Prepare a value for substitution into a query string.

#### Instances

Instances details

ToField Value Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Value -> Action Source #
ToField ByteString Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: ByteString -> Action Source #
ToField ByteString Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: ByteString -> Action Source #
ToField Int16 Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Int16 -> Action Source #
ToField Int32 Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Int32 -> Action Source #
ToField Int64 Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Int64 -> Action Source #
ToField Int8 Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Int8 -> Action Source #
ToField Word16 Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Word16 -> Action Source #
ToField Word32 Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Word32 -> Action Source #
ToField Word64 Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Word64 -> Action Source #
ToField Word8 Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Word8 -> Action Source #
ToField Oid Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Oid -> Action Source #
ToField HStoreBuilder Source # |
Instance details Defined in Database.PostgreSQL.Simple.HStore.Implementation Methods toField :: HStoreBuilder -> Action Source #
ToField HStoreList Source # |
Instance details Defined in Database.PostgreSQL.Simple.HStore.Implementation Methods toField :: HStoreList -> Action Source #
ToField HStoreMap Source # |
Instance details Defined in Database.PostgreSQL.Simple.HStore.Implementation Methods toField :: HStoreMap -> Action Source #
ToField Date Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Date -> Action Source #
ToField LocalTimestamp Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: LocalTimestamp -> Action Source #
ToField UTCTimestamp Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: UTCTimestamp -> Action Source #
ToField ZonedTimestamp Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: ZonedTimestamp -> Action Source #
ToField Action Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Action -> Action Source #
ToField Default Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Default -> Action Source #
ToField Identifier Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Identifier -> Action Source #
ToField Null Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Null -> Action Source #
ToField QualifiedIdentifier Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: QualifiedIdentifier -> Action Source #
ToField Scientific Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Scientific -> Action Source #
ToField Text Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Text -> Action Source #
ToField Text Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Text -> Action Source #
ToField Day Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Day -> Action Source #
ToField NominalDiffTime Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: NominalDiffTime -> Action Source #
ToField UTCTime Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: UTCTime -> Action Source #
ToField CalendarDiffTime Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: CalendarDiffTime -> Action Source #
ToField LocalTime Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: LocalTime -> Action Source #
ToField TimeOfDay Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: TimeOfDay -> Action Source #
ToField ZonedTime Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: ZonedTime -> Action Source #
ToField UUID Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: UUID -> Action Source #
ToField Integer Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Integer -> Action Source #
ToField Bool Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Bool -> Action Source #
ToField Double Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Double -> Action Source #
ToField Float Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Float -> Action Source #
ToField Int Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Int -> Action Source #
ToField Word Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Word -> Action Source #
ToField (CI Text) Source # | citext
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: CI Text -> Action Source #
ToField (CI Text) Source # | citext
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: CI Text -> Action Source #
ToField a => ToField (Identity a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Identity a -> Action Source #
ToJSON a => ToField (Aeson a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Newtypes Methods toField :: Aeson a -> Action Source #
ToField (PGRange Int16) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Int16 -> Action Source #
ToField (PGRange Int32) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Int32 -> Action Source #
ToField (PGRange Int64) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Int64 -> Action Source #
ToField (PGRange Int8) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Int8 -> Action Source #
ToField (PGRange Word16) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Word16 -> Action Source #
ToField (PGRange Word32) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Word32 -> Action Source #
ToField (PGRange Word64) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Word64 -> Action Source #
ToField (PGRange Word8) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Word8 -> Action Source #
ToField (PGRange Date) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Date -> Action Source #
ToField (PGRange LocalTimestamp) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange LocalTimestamp -> Action Source #
ToField (PGRange UTCTimestamp) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange UTCTimestamp -> Action Source #
ToField (PGRange ZonedTimestamp) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange ZonedTimestamp -> Action Source #
ToField (PGRange Scientific) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Scientific -> Action Source #
ToField (PGRange Day) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Day -> Action Source #
ToField (PGRange NominalDiffTime) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange NominalDiffTime -> Action Source #
ToField (PGRange UTCTime) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange UTCTime -> Action Source #
ToField (PGRange LocalTime) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange LocalTime -> Action Source #
ToField (PGRange TimeOfDay) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange TimeOfDay -> Action Source #
ToField (PGRange ZonedTime) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange ZonedTime -> Action Source #
ToField (PGRange Integer) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Integer -> Action Source #
ToField (PGRange Double) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Double -> Action Source #
ToField (PGRange Float) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Float -> Action Source #
ToField (PGRange Int) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Int -> Action Source #
ToField (PGRange Word) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Range Methods toField :: PGRange Word -> Action Source #
ToField (Binary ByteString) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Binary ByteString -> Action Source #
ToField (Binary ByteString) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Binary ByteString -> Action Source #
ToField a => ToField (In [a]) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: In [a] -> Action Source #
ToField a => ToField (PGArray a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: PGArray a -> Action Source #
ToRow a => ToField (Values a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Values a -> Action Source #
ToField a => ToField (Vector a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Vector a -> Action Source #
ToField a => ToField (Maybe a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Maybe a -> Action Source #
ToField [Char] Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: [Char] -> Action Source #
ToField a => ToField (Const a b) Source # |
Instance details Defined in Database.PostgreSQL.Simple.ToField Methods toField :: Const a b -> Action Source #

toJSONField :: ToJSON a => a -> Action Source #

Convert a Haskell value to JSON using `toEncoding`.

This can be used as the default implementation for the `toField` method for Haskell types that have a JSON representation in PostgreSQL.

inQuotes :: Builder -> Builder Source #

Surround a string with single-quote characters: "`'`"

This function does not perform any other escaping.