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

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.