PCLT-DB-0.1.1: An addon to PCLT package: enchance PCLT catalog with PostgreSQL powers.




An attemt of generalization of "read from DB" operation.



type NoMoreThanOne_shoulditbe = BoolSource

Type aliase for use by readOneFromDB.

class (Typeable readable, Show pk) => ReadableFromDB readable pk whereSource

It's recommended to use newtypes for subject type variable ("readable"), when it is composite (like tuple, Either, Map or other). Reason for that is described near the ShowAsPCSI instaniation for AddressedReadFromDBError.


readFromDB :: Connection -> pk -> IO [Either AddressedReadFromDBError readable]Source

Read rows from DB and parse each at once using parseDBrow class method

parseDBrow :: Connection -> pk -> Map FieldName SqlValue -> IO (Either AddressedReadFromDBError readable)Source

readOneFromDB :: Connection -> pk -> NoMoreThanOne_shoulditbe -> IO (Either AddressedReadFromDBError readable)Source

Class method derived from readFromDB and parseDBrow. No need to overload it, if not for special cases.

data AddressedReadFromDBError Source

A wrapper around ReadFromDBError, added information about type of read subject and by showing the primary key.


If PCLT is to be used for representation of AddressedReadFromDBError then user must declare an additional localizable template in his PCLT catalog with ID of form:

"ARFDBE_SDLR." ++ (show $ arfdbeEntityType err)

, where the show arfdbeEntityType will include full modules path of type. The templete content if not important - leave it empty, but what is important - is it's SDL requirement. This SDL requirement wil be in effect for the representation of AddressedReadFromDBError.

For more information on that, see description for ShowAsPCSI instance for AddressedReadFromDBError - in module Database.ReadableFromDB__.

wrapParseResult_1row :: (Typeable readable, Show pk) => pk -> Either ReadFromDBError readable -> Either AddressedReadFromDBError readableSource

In case of error it wraps it ReadFromDBError into AddressedReadFromDBError.


rightType_formReadResOrErr :: (Typeable left, Typeable right) => Either left right -> TypeRepSource

Return the TypeRep of what can be under Right in Either

takeFieldValue :: Convertible SqlValue a => FieldName -> Map FieldName SqlValue -> aSource

This is better than row ! field_name, because if an error occurs (field not found), then it returns in error message this field name.

takeUFieldValue :: Convertible SqlValue a => FieldName -> Map FieldName SqlValue -> aSource

Uppercase given field name, and apply it with takeFieldValue.

uppercaseMapKeys :: Map String a -> Map String aSource

WARNING !!! HDBC lowercases field names, when using fetchAllRowsMap.

liftInList :: a -> [a]Source

 liftInList a = a : []