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

Stabilityexperimental
MaintainerLeon P Smith <leon@melding-monads.com>
Safe HaskellNone

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.

Instances

Show Action 
Typeable Action 
ToField Action 

class ToField a whereSource

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

Methods

toField :: a -> ActionSource

Prepare a value for substitution into a query string.

Instances

toJSONField :: ToJSON a => a -> ActionSource

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

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

This function does not perform any other escaping.