postgresql-simple-0.5.1.2: 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.

Methods

toField :: a -> Action Source

Prepare a value for substitution into a query string.

Instances

ToField Bool Source 
ToField Double Source 
ToField Float Source 
ToField Int Source 
ToField Int8 Source 
ToField Int16 Source 
ToField Int32 Source 
ToField Int64 Source 
ToField Integer Source 
ToField Word Source 
ToField Word8 Source 
ToField Word16 Source 
ToField Word32 Source 
ToField Word64 Source 
ToField ByteString Source 
ToField Scientific Source 
ToField ByteString Source 
ToField Text Source 
ToField UTCTime Source 
ToField Value Source 
ToField Text Source 
ToField Oid Source 
ToField LocalTime Source 
ToField ZonedTime Source 
ToField TimeOfDay Source 
ToField NominalDiffTime Source 
ToField Day Source 
ToField UUID Source 
ToField QualifiedIdentifier Source 
ToField Identifier Source 
ToField Default Source 
ToField Null Source 
ToField Action Source 
ToField Date Source 
ToField ZonedTimestamp Source 
ToField UTCTimestamp Source 
ToField LocalTimestamp Source 
ToField HStoreMap Source 
ToField HStoreList Source 
ToField HStoreBuilder Source 
ToField [Char] Source 
ToField a => ToField (Maybe a) Source 
ToField a => ToField (Vector a) Source 
ToRow a => ToField (Values a) Source 
ToField a => ToField (PGArray a) Source 
ToField (Binary ByteString) Source 
ToField (Binary ByteString) Source 
ToField a => ToField (In [a]) 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.