-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Generic deserialization of PostgreSQL rows based on column names
--
-- See README.md
@package postgresql-named
@version 0.1.0
-- | This module provides the machinery for implementing instances of
-- FromRow that deserialize based on the names of columns instead
-- of the positions of individual fields. This is particularly convenient
-- when deserializing to a Haskell record and you want the field names
-- and column names to match up. In this case gFromRow can be used
-- as a generic implementation of fromRow.
module Database.PostgreSQL.Simple.FromRow.Named
-- | Deserialize a type with a single record constructor by matching the
-- names of columns and record fields. Currently the complexity is
-- O(n^2) where n is the number of record fields.
--
-- This is intended to be used as the implementation of fromRow.
--
-- Throws
--
--
-- - NoSuchColumn if there is a field for which there is no
-- column with the same name.
-- - TooManyColumns if there more columns (counting both named
-- and unnamed columns) than record fields.
--
gFromRow :: forall a modName tyName constrName fields xs. (Generic a, HasDatatypeInfo a, All2 FromField (Code a), KnownSymbol modName, KnownSymbol tyName, DatatypeInfoOf a ~ ADT modName tyName '[Record constrName fields], Code a ~ '[xs], DemoteFieldInfos fields xs) => RowParser a
-- | This is a wrapper around fieldByNameWith that gets the
-- FieldParser via the typeclass instance. Take a look at the docs
-- for fieldByNameWith for the details of this function.
fieldByName :: FromField a => ByteString -> RowParser a
-- | This is similar to fieldWith but instead of trying to
-- deserialize the field at the current position it goes through all
-- fields in the current row (starting at the beginning not the current
-- position) and tries to deserialize the first field with a matching
-- column name.
fieldByNameWith :: FieldParser a -> ByteString -> RowParser a
-- | Thrown when there is no column of the given name.
data NoSuchColumn
NoSuchColumn :: ByteString -> NoSuchColumn
-- | Thrown by gFromRow when trying to deserialize to a record that
-- has less fields than the current row has columns (counting both named
-- and unnamed columns).
data TooManyColumns
TooManyColumns :: !Word -> !Word -> TooManyColumns
-- | The expected number of record fields.
[numRecordFields] :: TooManyColumns -> !Word
-- | The number of columns in the row that should have been deserialized.
[numColumns] :: TooManyColumns -> !Word
instance GHC.Classes.Ord Database.PostgreSQL.Simple.FromRow.Named.TooManyColumns
instance GHC.Classes.Eq Database.PostgreSQL.Simple.FromRow.Named.TooManyColumns
instance GHC.Show.Show Database.PostgreSQL.Simple.FromRow.Named.TooManyColumns
instance GHC.Classes.Ord Database.PostgreSQL.Simple.FromRow.Named.NoSuchColumn
instance GHC.Classes.Eq Database.PostgreSQL.Simple.FromRow.Named.NoSuchColumn
instance GHC.Show.Show Database.PostgreSQL.Simple.FromRow.Named.NoSuchColumn
instance GHC.Exception.Exception Database.PostgreSQL.Simple.FromRow.Named.NoSuchColumn
instance GHC.Exception.Exception Database.PostgreSQL.Simple.FromRow.Named.TooManyColumns