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

Copyright(c) 2011 MailRank Inc.
(c) 2011-2012 Leon P Smith
LicenseBSD3
MaintainerLeon P Smith <leon@melding-monads.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Database.PostgreSQL.Simple.ToField

Description

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

Synopsis

Documentation

data Action #

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

class ToField a where #

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

Minimal complete definition

toField

Methods

toField :: a -> Action #

Prepare a value for substitution into a query string.

Instances

ToField Bool # 

Methods

toField :: Bool -> Action #

ToField Double # 

Methods

toField :: Double -> Action #

ToField Float # 

Methods

toField :: Float -> Action #

ToField Int # 

Methods

toField :: Int -> Action #

ToField Int8 # 

Methods

toField :: Int8 -> Action #

ToField Int16 # 

Methods

toField :: Int16 -> Action #

ToField Int32 # 

Methods

toField :: Int32 -> Action #

ToField Int64 # 

Methods

toField :: Int64 -> Action #

ToField Integer # 

Methods

toField :: Integer -> Action #

ToField Word # 

Methods

toField :: Word -> Action #

ToField Word8 # 

Methods

toField :: Word8 -> Action #

ToField Word16 # 

Methods

toField :: Word16 -> Action #

ToField Word32 # 

Methods

toField :: Word32 -> Action #

ToField Word64 # 

Methods

toField :: Word64 -> Action #

ToField ByteString # 

Methods

toField :: ByteString -> Action #

ToField ByteString # 

Methods

toField :: ByteString -> Action #

ToField Scientific # 

Methods

toField :: Scientific -> Action #

ToField Text # 

Methods

toField :: Text -> Action #

ToField UTCTime # 

Methods

toField :: UTCTime -> Action #

ToField Value # 

Methods

toField :: Value -> Action #

ToField Text # 

Methods

toField :: Text -> Action #

ToField Oid # 

Methods

toField :: Oid -> Action #

ToField LocalTime # 

Methods

toField :: LocalTime -> Action #

ToField ZonedTime # 

Methods

toField :: ZonedTime -> Action #

ToField TimeOfDay # 

Methods

toField :: TimeOfDay -> Action #

ToField NominalDiffTime # 
ToField Day # 

Methods

toField :: Day -> Action #

ToField UUID # 

Methods

toField :: UUID -> Action #

ToField Date # 

Methods

toField :: Date -> Action #

ToField ZonedTimestamp # 
ToField UTCTimestamp # 
ToField LocalTimestamp # 
ToField QualifiedIdentifier # 
ToField Identifier # 

Methods

toField :: Identifier -> Action #

ToField Default # 

Methods

toField :: Default -> Action #

ToField Null # 

Methods

toField :: Null -> Action #

ToField Action # 

Methods

toField :: Action -> Action #

ToField HStoreMap # 

Methods

toField :: HStoreMap -> Action #

ToField HStoreList # 

Methods

toField :: HStoreList -> Action #

ToField HStoreBuilder # 
ToField [Char] # 

Methods

toField :: [Char] -> Action #

ToField a => ToField (Maybe a) # 

Methods

toField :: Maybe a -> Action #

ToField a => ToField (Vector a) # 

Methods

toField :: Vector a -> Action #

ToRow a => ToField (Values a) # 

Methods

toField :: Values a -> Action #

ToField a => ToField (PGArray a) # 

Methods

toField :: PGArray a -> Action #

ToField (Binary ByteString) # 
ToField (Binary ByteString) # 
ToField a => ToField (In [a]) # 

Methods

toField :: In [a] -> Action #

ToField (PGRange Double) # 
ToField (PGRange Float) # 
ToField (PGRange Int) # 

Methods

toField :: PGRange Int -> Action #

ToField (PGRange Int8) # 

Methods

toField :: PGRange Int8 -> Action #

ToField (PGRange Int16) # 
ToField (PGRange Int32) # 
ToField (PGRange Int64) # 
ToField (PGRange Integer) # 
ToField (PGRange Word) # 

Methods

toField :: PGRange Word -> Action #

ToField (PGRange Word8) # 
ToField (PGRange Word16) # 
ToField (PGRange Word32) # 
ToField (PGRange Word64) # 
ToField (PGRange Scientific) # 
ToField (PGRange UTCTime) # 
ToField (PGRange LocalTime) # 
ToField (PGRange ZonedTime) # 
ToField (PGRange TimeOfDay) # 
ToField (PGRange NominalDiffTime) # 
ToField (PGRange Day) # 

Methods

toField :: PGRange Day -> Action #

ToField (PGRange Date) # 

Methods

toField :: PGRange Date -> Action #

ToField (PGRange ZonedTimestamp) # 
ToField (PGRange UTCTimestamp) # 
ToField (PGRange LocalTimestamp) # 

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

Convert a Haskell value to a JSON Value using toJSON and convert that to a field using toField.

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 #

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

This function does not perform any other escaping.