ihp-1.5.0: Haskell Web Framework
Copyright(c) digitally induced GmbH 2025
Safe HaskellNone
LanguageGHC2021

IHP.Hasql.FromRow

Description

This module provides FromRowHasql, a typeclass parallel to postgresql-simple's FromRow, for decoding database rows using hasql's more efficient prepared statement approach.

Instances are generated by the SchemaCompiler with explicit inline decoders in idiomatic hasql applicative style.

Also provides parser functions used by the generated decoders for custom PostgreSQL types.

Synopsis

Documentation

class FromRowHasql a where Source #

Typeclass for types that can be decoded from a hasql result row

This is the hasql equivalent of postgresql-simple's FromRow class. The SchemaCompiler generates instances for all model types using idiomatic hasql applicative style with explicit inline decoders.

Methods

hasqlRowDecoder :: Row a Source #

Decoder for a single row

Instances

Instances details
HasqlDecodeColumn a => FromRowHasql (Only a) Source # 
Instance details

Defined in IHP.Hasql.FromRow

(HasqlDecodeColumn a, HasqlDecodeColumn b) => FromRowHasql (a, b) Source # 
Instance details

Defined in IHP.Hasql.FromRow

Methods

hasqlRowDecoder :: Row (a, b) Source #

(HasqlDecodeColumn a, HasqlDecodeColumn b, HasqlDecodeColumn c) => FromRowHasql (a, b, c) Source # 
Instance details

Defined in IHP.Hasql.FromRow

Methods

hasqlRowDecoder :: Row (a, b, c) Source #

(HasqlDecodeColumn a, HasqlDecodeColumn b, HasqlDecodeColumn c, HasqlDecodeColumn d) => FromRowHasql (a, b, c, d) Source # 
Instance details

Defined in IHP.Hasql.FromRow

Methods

hasqlRowDecoder :: Row (a, b, c, d) Source #

(HasqlDecodeColumn a, HasqlDecodeColumn b, HasqlDecodeColumn c, HasqlDecodeColumn d, HasqlDecodeColumn e) => FromRowHasql (a, b, c, d, e) Source # 
Instance details

Defined in IHP.Hasql.FromRow

Methods

hasqlRowDecoder :: Row (a, b, c, d, e) Source #

class HasqlDecodeColumn a where Source #

Typeclass for building column-level row decoders, handling nullable/non-nullable. Uses IsScalar from hasql-mapping for value-level decoding.

Instances

Instances details
HasqlDecodeColumn Int Source #

IHP's schema maps SQL INT (int4) to Haskell Int, but hasql-mapping's IsScalar Int instance uses int8 (bigint). Override to match IHP conventions.

Instance details

Defined in IHP.Hasql.FromRow

IsScalar a => HasqlDecodeColumn a Source # 
Instance details

Defined in IHP.Hasql.FromRow

IsScalar (PrimaryKey table) => HasqlDecodeColumn (Id' table) Source #

Decode Id table' by decoding the primary key type and wrapping with Id

Instance details

Defined in IHP.Hasql.FromRow

Methods

hasqlColumnDecoder :: Row (Id' table) Source #

IsScalar (PrimaryKey table) => HasqlDecodeColumn (Maybe (Id' table)) Source #

Decode 'Maybe (Id' table)' for nullable foreign keys

Instance details

Defined in IHP.Hasql.FromRow

Methods

hasqlColumnDecoder :: Row (Maybe (Id' table)) Source #

HasqlDecodeColumn (Maybe Int) Source # 
Instance details

Defined in IHP.Hasql.FromRow

IsScalar a => HasqlDecodeColumn (Maybe a) Source # 
Instance details

Defined in IHP.Hasql.FromRow

Orphan instances

IsScalar Integer Source #

IHP's schema maps SQL BIGINT/BIGSERIAL to Haskell Integer (see atomicType in SchemaCompiler). hasql-mapping ships no 'IsScalar Integer' instance, so BIGSERIAL primary keys (and foreign keys referencing them) fail to typecheck in generated RowDecoder modules with No instance for Mapping.IsScalar Integer. Provide one backed by the int8 codec, mirroring the 'DefaultParamEncoder Integer' instance in IHP.Hasql.Encoders.

Instance details

IsScalar (PrimaryKey table) => IsScalar (Id' table) Source #

IsScalar instance for Id' so that Id columns can use encoder and decoder directly in generated code, without manual wrapping/unwrapping.

Instance details

Methods

encoder :: Value (Id' table) Source #

decoder :: Value (Id' table) Source #