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

Portability | portable
Stability | experimental
Maintainer | Leon P Smith <leon@melding-monads.com>
Safe Haskell | None

Database.PostgreSQL.Simple.ToField

Description

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

Synopsis

- data Action
  - = Plain Builder
  - | Escape ByteString
  - | EscapeByteA ByteString
  - | Many [Action]
- class ToField a where
  - toField :: a -> Action
- inQuotes :: Builder -> Builder

# 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.
Many [Action] | Concatenate a series of rendering actions.

Instances

Show Action |
Typeable Action |
ToField Action |

class ToField a where

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

Methods

toField :: a -> Action

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 Text |
ToField Text |
ToField ByteString |
ToField Oid |
ToField LocalTime |
ToField ZonedTime |
ToField TimeOfDay |
ToField UTCTime |
ToField Day |
ToField Date |
ToField ZonedTimestamp |
ToField UTCTimestamp |
ToField LocalTimestamp |
ToField Null |
ToField Action |
ToField [Char] |
ToField a => ToField (Maybe a) |
ToField (Binary ByteString) |
ToField (Binary ByteString) |
ToField a => ToField (In [a]) |

inQuotes :: Builder -> Builder

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

This function does not perform any other escaping.