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 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.

class ToField a where Source #

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

Minimal complete definition

toField

Methods

toField :: a -> Action Source #

Prepare a value for substitution into a query string.

Instances

ToField Bool Source # 

Methods

toField :: Bool -> Action Source #

ToField Double Source # 
ToField Float Source # 

Methods

toField :: Float -> Action Source #

ToField Int Source # 

Methods

toField :: Int -> Action Source #

ToField Int8 Source # 

Methods

toField :: Int8 -> Action Source #

ToField Int16 Source # 

Methods

toField :: Int16 -> Action Source #

ToField Int32 Source # 

Methods

toField :: Int32 -> Action Source #

ToField Int64 Source # 

Methods

toField :: Int64 -> Action Source #

ToField Integer Source # 
ToField Word Source # 

Methods

toField :: Word -> Action Source #

ToField Word8 Source # 

Methods

toField :: Word8 -> Action Source #

ToField Word16 Source # 
ToField Word32 Source # 
ToField Word64 Source # 
ToField ByteString Source # 
ToField ByteString Source # 
ToField Scientific Source # 
ToField Text Source # 

Methods

toField :: Text -> Action Source #

ToField UTCTime Source # 
ToField Value Source # 

Methods

toField :: Value -> Action Source #

ToField Text Source # 

Methods

toField :: Text -> Action Source #

ToField Oid Source # 

Methods

toField :: Oid -> Action Source #

ToField LocalTime Source # 
ToField ZonedTime Source # 
ToField TimeOfDay Source # 
ToField NominalDiffTime Source # 
ToField Day Source # 

Methods

toField :: Day -> Action Source #

ToField UUID Source # 

Methods

toField :: UUID -> Action Source #

ToField Date Source # 

Methods

toField :: Date -> Action Source #

ToField ZonedTimestamp Source # 
ToField UTCTimestamp Source # 
ToField LocalTimestamp Source # 
ToField QualifiedIdentifier Source # 
ToField Identifier Source # 
ToField Default Source # 
ToField Null Source # 

Methods

toField :: Null -> Action Source #

ToField Action Source # 
ToField HStoreMap Source # 
ToField HStoreList Source # 
ToField HStoreBuilder Source # 
ToField [Char] Source # 

Methods

toField :: [Char] -> Action Source #

ToField a => ToField (Maybe a) Source # 

Methods

toField :: Maybe a -> Action Source #

ToField a => ToField (Vector a) Source # 

Methods

toField :: Vector a -> Action Source #

ToRow a => ToField (Values a) Source # 

Methods

toField :: Values a -> Action Source #

ToField a => ToField (PGArray a) Source # 

Methods

toField :: PGArray a -> Action Source #

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

Methods

toField :: In [a] -> Action Source #

ToField (PGRange Double) Source # 
ToField (PGRange Float) Source # 
ToField (PGRange Int) Source # 
ToField (PGRange Int8) Source # 
ToField (PGRange Int16) Source # 
ToField (PGRange Int32) Source # 
ToField (PGRange Int64) Source # 
ToField (PGRange Integer) Source # 
ToField (PGRange Word) Source # 
ToField (PGRange Word8) Source # 
ToField (PGRange Word16) Source # 
ToField (PGRange Word32) Source # 
ToField (PGRange Word64) Source # 
ToField (PGRange Scientific) Source # 
ToField (PGRange UTCTime) Source # 
ToField (PGRange LocalTime) Source # 
ToField (PGRange ZonedTime) Source # 
ToField (PGRange TimeOfDay) Source # 
ToField (PGRange NominalDiffTime) Source # 
ToField (PGRange Day) Source # 
ToField (PGRange Date) Source # 
ToField (PGRange ZonedTimestamp) Source # 
ToField (PGRange UTCTimestamp) Source # 
ToField (PGRange LocalTimestamp) Source # 

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

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 Source #

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

This function does not perform any other escaping.