rel8
Hey! Hey! Can u rel8?
https://github.com/circuithub/rel8
Version on this page: | 1.4.1.0 |
LTS Haskell 21.25: | 1.4.1.0 |
Stackage Nightly 2023-06-21: | 1.4.1.0 |
Latest on Hackage: | 1.5.0.0 |
rel8-1.4.1.0@sha256:84e20d00567be72ca6944e5df5ed0fb00fdaf95f046f4cec633b870319a2fbaf,5264
Module documentation for 1.4.1.0
Welcome!
Welcome to Rel8! Rel8 is a Haskell library for interacting with PostgreSQL databases, built on top of the fantastic Opaleye library.
The main objectives of Rel8 are:
-
Conciseness: Users using Rel8 should not need to write boiler-plate code. By using expressive types, we can provide sufficient information for the compiler to infer code whenever possible.
-
Inferrable: Despite using a lot of type level magic, Rel8 aims to have excellent and predictable type inference.
-
Familiar: writing Rel8 queries should feel like normal Haskell programming.
Rel8 was presented at ZuriHac 2021. If you want to have a brief overview of what Rel8 is, and a tour of the API - check out the video below:
For more details, check out the official documentation.
Changes
1.4.1.0 (2023-01-19)
New features
- Rel8 now supports window functions. See the “Window functions” section of the
Rel8
module documentation for more details. (#182) Query
now hasMonoid
andSemigroup
instances. (#207)createOrReplaceView
has been added (to runCREATE OR REPLACE VIEW
). (#209 and #212)deriving Rel8able
now supports more polymorphism. (#215)- Support GHC 9.4 (#199)
Bug fixes
- Insertion of
DEFAULT
values has been fixed. (#206) - Avoid some exponential SQL generation in
Rel8.Tabulate.alignWith
. (#213) nextVal
has been fixed to work with case-sensitive sequence names. (#217)
Other
- Correct the documentation for “Supplying
Rel8able
instances” (#200) - Removed some redundant internal code (#202)
- Rel8 is now less dependant on the internal Opaleye API. (#204)
1.4.0.0 (2022-08-17)
Breaking changes
- The behavior of
greatest
/least
has been corrected, and was previously flipped. (#183)
New features
NullTable
/HNull
have been added. This is an alternative toMaybeTable
that doesn’t use a tag columns. It’s less flexible (noFunctor
orApplicative
instance) and is meaningless when used with a table that has no non-nullable columns (so nestingNullTable
is redundant). But in situations where the underlyingTable
does have non-nullable columns, it can losslessly converted to and fromMaybeTable
. It is useful for embedding into a base table when you don’t want to store the extra tag column in your schema. (#173)- Add
fromMaybeTable
. (#179) - Add
alignMaybeTable
. (#196)
Improvements
- Optimize implementation of
AltTable
forTabulation
(#178)
Other
- Documentation improvements for
HADT
. (#177) - Document example usage of
groupBy
. (#184) - Build with and require Opaleye >= 0.9.3.3. (#190)
- Build with
hasql
1.6. (#195)
1.3.1.0 (2022-01-20)
Other
- Rel8 now requires Opaleye >= 0.9.1. (#165)
1.3.0.0 (2022-01-31)
Breaking changes
div
andmod
have been changed to match Haskell semantics. If you need the PostgreSQLdiv()
andmod()
functions, usequot
andrem
. While this is not an API change, we feel this is a breaking change in semantics and have bumped the major version number. (#155)
New features
divMod
andquotRem
functions have been added, matching Haskell’sPrelude
functions. (#155)avg
andmode
aggregation functions to find the mean value of an expression, or the most common row in a query, respectively. (#152)- The full
EqTable
andOrdTable
classes have been exported, allowing for instances to be manually created. (#157) - Added
like
andilike
(for theLIKE
andILIKE
operators). (#146)
Other
- Rel8 now requires Opaleye 0.9. (#158)
- Rel8’s test suite supports Hedgehog 1.1. (#160)
- The documentation for binary operations has been corrected. (#162)
1.2.2.0 (2021-11-21)
Other
1.2.1.0 (2021-11-21)
New features
-
castTable
has been added, which casts all columns selected from inQuery
according to the types of columns. This can occasionally be useful when usingmany
/some
on older PostgreSQL versions. (#137) -
Added
<:
,<=:
,>:
,>=:
,greatest
andleast
, which sort all columns in a table lexicographically. These operators are like the<.
operators which operate onExpr
s, but the<:
operate on entire tables. (#139)
Other
- Support opaleye-0.8 (#142)
1.2.0.0 (2021-10-22)
New features
- New
$*
and$+
operators for projecting out ofListTable
andNonEmptyTable
respectively (analogous to the existing$?
forMaybeTable
). (#125)
Bug fixes
-
Fix
UPSERT
support (and add tests), which was broken due to a typo inside Rel8 that made it impossible to constructProjection
s which are needed byUPSERT
. (#134) -
Remove
DBMin
andDBMax
instances forBool
, which are invalid as far as Postgres is concerned.and
andor
can be used to achieve the same thing. (#126) -
Fix
aggregateMaybeTable
,aggregateEitherTable
andaggregateTheseTable
, which generated invalid SQL previously. (#127)
Breaking changes
rebind
now takes an additional argument for the “name” of the binding. (#128)
1.1.0.0 (2021-07-16)
New features
-
You can derive
Rel8able
for “vanilla” higher-kinded data types - data types that don’t use theColumn
type family. For example, the following is now possible:data MyTable f = MyTable { myTableX :: f Int32 , myTableY :: f Text } deriving (Generic, Rel8able)
-
The
Projectable
andBiprojectable
type classes have been introduced. These classes model a type of functors and bifunctors (respectively) on tables, where the mapping function is only able to rearrange columns. For example, the following is now possible:x <- project myTableX <$> many ...
-
Insert
‘sonConflict
field now has a new option -DoUpdate
. This maps to PostgreSQL’sON CONFLICT DO UPDATE
syntax, which provides upsert support. (#85) -
Insert
,Update
andDelete
has all been expanded to work withQuery
s. In particular:Delete
now supports aUSING
sub-queryUpdate
now supports aFROM
sub-queryInsert
can delete the result of any arbitraryQuery
(providing the types match)
-
The new
Rel8.Tabulate
module has been added, which gives aMap
-esque interface to writing and composing queries. (#70) -
The new
indexed
Query -> Query
function was added. This function augments each row in a query with it’s 0-based index. (#117)
Breaking changes
-
Insert
,Delete
andUpdate
have all changed. In particular, forInsert
users should now replacerows = xs
withrows = values xs
. (#85) -
Rename
whereExists
andwhereNotExists
topresent
andabsent
respectively. (#57) -
Simplify
evaluate
to run directly inside theQuery
monad, rendering theEvaluate
monad unnecessary. (#56) -
The
Labelable
type class has been removed as it’s no longer necessary. This class was mostly internal, though was visible in some public API functions. (#76) -
EitherTable
,ListTable
,MaybeTable
,NonEmptyTable
andTheseTable
now all have an extra parameter which tracks the context of the table. If you manually specified any types before, you need to provide this parameter - usuallyExpr
will be the correct choice. (#101) -
We’ve done a lot of work to simplify the internals of Rel8, but some of these are breaking changes. However, most of these API changes shouldn’t affect users as they are mostly types used in type inference, or affect classes where users don’t need to define their own instances.
- The kind of a
Rel8able
is now(Type -> Type) -> Type
. Previously it was(X -> Type) -> Type
. Table
has a new associated type -FromExprs
. This was previously an open type family.Table
has a new associated type -Transpose
- andRecontextualise
has been renamed toTransposes
. ThisTransposes
class now operates in terms ofTranspose
.
- The kind of a
-
select
,insert
,update
anddelete
now produce HasqlStatement
s, rather than actually running the statement as IO. This allows Rel8 to be used with transaction/connection-managing monads likehasql-transaction
. (#94)
Bug fixes
-
Fixes a bug where cartesian products of queries using
catListTable
,catNonEmptyTable
,catList
andcatNonEmpty
would incorrectly be zipped instead. (#61) -
Require Opaleye 0.7.3.0. This version has better support for lateral queries, which can improve query plans, especially in
optional
/LEFT JOIN
(#72) -
Rel8 now compiles with GHC 9. (#97)
Other changes
-
exists
is now implemented in terms of the SQLEXISTS
keyword. (#69) -
alignBy
no longer requiresTable
s. (#67)
1.0.0.1 (2021-06-21)
This release contains various fixes for documentation.
1.0.0.0 (2021-06-18)
- Initial release.