opaleye: An SQL-generating DSL targeting PostgreSQL

[ bsd3, database, library ] [ Propose Tags ] [ Report a vulnerability ]

An SQL-generating DSL targeting PostgreSQL. Allows Postgres queries to be written within Haskell in a typesafe and composable fashion.


[Skip to Readme]

Modules

[Last Documentation]

  • Opaleye
    • Opaleye.Adaptors
    • Opaleye.Aggregate
    • Opaleye.Binary
    • Opaleye.Column
    • Opaleye.Distinct
    • Opaleye.Exists
    • Experimental
      • Opaleye.Experimental.Enum
    • Opaleye.Field
    • Opaleye.FunctionalJoin
    • Internal
      • Opaleye.Internal.Aggregate
      • Opaleye.Internal.Binary
      • Opaleye.Internal.Column
      • Opaleye.Internal.Constant
      • Opaleye.Internal.Distinct
      • HaskellDB
        • Opaleye.Internal.HaskellDB.PrimQuery
        • Opaleye.Internal.HaskellDB.Sql
          • Opaleye.Internal.HaskellDB.Sql.Default
          • Opaleye.Internal.HaskellDB.Sql.Generate
          • Opaleye.Internal.HaskellDB.Sql.Print
      • Opaleye.Internal.Helpers
      • Opaleye.Internal.Inferrable
      • Opaleye.Internal.JSONBuildObjectFields
      • Opaleye.Internal.Join
      • Opaleye.Internal.Lateral
      • Opaleye.Internal.Locking
      • Opaleye.Internal.Manipulation
      • Opaleye.Internal.Map
      • Opaleye.Internal.MaybeFields
      • Opaleye.Internal.Operators
      • Opaleye.Internal.Optimize
      • Opaleye.Internal.Order
      • Opaleye.Internal.PGTypes
      • Opaleye.Internal.PGTypesExternal
      • Opaleye.Internal.PackMap
      • Opaleye.Internal.PrimQuery
      • Opaleye.Internal.Print
      • Opaleye.Internal.QueryArr
      • Opaleye.Internal.Rebind
      • Opaleye.Internal.RunQuery
      • Opaleye.Internal.RunQueryExternal
      • Opaleye.Internal.Sql
      • Opaleye.Internal.Table
      • Opaleye.Internal.Tag
      • Opaleye.Internal.TypeFamilies
      • Opaleye.Internal.Unpackspec
      • Opaleye.Internal.Values
      • Opaleye.Internal.Window
    • Opaleye.Join
    • Opaleye.Label
    • Opaleye.Lateral
    • Opaleye.Manipulation
    • Opaleye.MaybeFields
    • Opaleye.Operators
    • Opaleye.Order
    • Opaleye.RunSelect
    • Opaleye.Select
    • Opaleye.Sql
    • Opaleye.SqlTypes
    • Opaleye.Table
    • Opaleye.ToFields
    • Opaleye.TypeFamilies
    • Opaleye.Values
    • Opaleye.Window
    • Opaleye.With

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.2, 0.3, 0.3.1, 0.3.1.1, 0.3.1.2, 0.4.0.0, 0.4.1.0, 0.4.2.0, 0.5.0.0, 0.5.1.0, 0.5.1.1, 0.5.2.0, 0.5.2.1, 0.5.2.2, 0.5.3.0, 0.5.3.1, 0.5.4.0, 0.6.0.0, 0.6.1.0, 0.6.7000.0, 0.6.7001.0, 0.6.7002.0, 0.6.7003.0, 0.6.7003.1, 0.6.7004.0, 0.6.7004.1, 0.6.7004.2, 0.6.7005.0, 0.6.7006.0, 0.6.7006.1, 0.7.0.0, 0.7.1.0, 0.7.2.0, 0.7.3.0, 0.7.4.0, 0.7.5.0, 0.7.6.0, 0.7.6.1, 0.7.6.2, 0.8.0.0, 0.8.0.1, 0.8.1.0, 0.9.0.0, 0.9.1.0, 0.9.2.0, 0.9.3.0, 0.9.3.1, 0.9.3.2, 0.9.3.3, 0.9.4.0, 0.9.4.1, 0.9.5.0, 0.9.5.1, 0.9.6.0, 0.9.6.1, 0.9.6.2, 0.9.7.0, 0.10.0.0, 0.10.1.0, 0.10.1.1, 0.10.2.0, 0.10.2.1, 0.10.2.2, 0.10.2.3, 0.10.3.0, 0.10.3.1, 0.10.4.0 (info)
Change log CHANGELOG.md
Dependencies aeson (>=0.6 && <2.3), base (>=4.9 && <4.21), base16-bytestring (>=0.1.1.6 && <1.1), bytestring (>=0.10 && <0.13), case-insensitive (>=1.2 && <1.3), contravariant (>=1.2 && <1.6), postgresql-simple (>=0.6 && <0.8), pretty (>=1.1.1.0 && <1.2), product-profunctors (>=0.11.0.3 && <0.12), profunctors (>=4.0 && <5.7), scientific (>=0.3 && <0.4), semigroups (>=0.13 && <0.21), text (>=0.11 && <2.2), time-compat (>=1.9.5 && <1.12), time-locale-compat (>=0.1 && <0.2), transformers (>=0.3 && <0.7), uuid-types (>=1.0.5 && <1.1), void (>=0.4 && <0.8) [details]
Tested with ghc ==9.10, ghc ==9.8, ghc ==9.6, ghc ==9.4, ghc ==9.2, ghc ==9.0, ghc ==8.10, ghc ==8.8
License BSD-3-Clause
Copyright Copyright (c) 2014-2018 Purely Agile Limited; 2019-2024 Tom Ellis
Author
Maintainer Tom Ellis
Revised Revision 1 made by tomjaguarpaw at 2024-11-10T13:08:54Z
Category Database
Home page https://github.com/tomjaguarpaw/haskell-opaleye
Bug tracker https://github.com/tomjaguarpaw/haskell-opaleye/issues
Source repo head: git clone https://github.com/tomjaguarpaw/haskell-opaleye.git
Uploaded by tomjaguarpaw at 2024-10-04T19:56:46Z
Distributions LTSHaskell:0.10.4.0, NixOS:0.10.3.1, Stackage:0.10.4.0
Reverse Dependencies 9 direct, 2 indirect [details]
Downloads 32357 total (357 in the last 30 days)
Rating 2.5 (votes: 4) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2024-10-04 [all 2 reports]

Readme for opaleye-0.10.4.0

[back to package description]

Brief introduction to Opaleye Hackage versionStackage versionBuild status

Opaleye is a Haskell library that provides an SQL-generating embedded domain specific language for targeting Postgres. You need Opaleye if you want to use Haskell to write typesafe and composable code to query a Postgres database.

"Opaleye really is great. You've managed to bring what is so wonderful about relational databases and give it type safety and composition (i.e. what is wonderful about Haskell)" – Daniel Patterson, Position Development

"We use it for most of our DB code. It's very flexible and almost always as performant as manually written queries" – Adam Bergmark, Silk.co

"Opaleye is absolutely fantastic. It has been solid in production for years!" – Matt Wraith

"Opaleye just works, and it’s my personal recommendation ... I like it a lot" – William Yao

Opaleye allows you to define your database tables and write queries against them in Haskell code, and aims to be typesafe in the sense that if your code compiles then the generated SQL query will not fail at runtime. A wide range of SQL functionality is supported including inner and outer joins, restriction, aggregation, distinct, sorting and limiting, unions and differences. Facilities to insert to, update and delete from tables are also provided. Code written using Opaleye is composable at a very fine level of granularity, promoting code reuse and high levels of abstraction.

Getting Opaleye

Tutorials

Please get started with Opaleye by referring to these two tutorials

Advanced

Contact

Contact the author

The main author of Opaleye is Tom Ellis. He can be contacted via email.

File bugs

Please file bugs on the Opaleye GitHub issue tracking page.

Discuss and ask questions about Opaleye

You are welcome to use the Opaleye GitHub issue tracking page for discussion of or questions about Opaleye even if they don't relate to a bug or issue.

PRs

You are welcome to make PRs to Opaleye. If you would like to discuss the design of your PR before you start work on it feel free to do so by filing a new issue.

Internal modules

Opaleye exports a number of modules named Opaleye.Internal..... They are provided in case of urgent need for access to the internals, but they are not intended to be used by API consumers and if you find yourself repeatedly accessing them this is a sign that either you or Opaleye are doing something wrong. In such a case please file a bug.

The interface of Internal modules does not follow the PVP and may break between minor releases, so be careful.

Running tests

You must have running PostgreSQL server to run tests. Specify the database by setting the POSTGRES_CONNSTRING environment variable:

POSTGRES_CONNSTRING="user=tom dbname=opaleye_test" stack test

Commercial support

Commercial support for Opaleye is provided by Purely Agile.

Backup maintainers

The only person authorised to merge to master or upload this package to Hackage is Tom Ellis.

However, to ensure continuity of service to Opaleye users there are backup maintainers.

  • If Tom Ellis is unavailable or unresponsive to maintenance requests for three months then full ownership of the project, including the GitHub repository, Hackage upload rights, and the right to amend this backup maintainers policy, passes to Oliver Charles (ollie@ocharles.org.uk).

  • If Tom Ellis is unavailable or unresponsive to maintenance requests for four months, and this policy has not been changed to the contrary, then full ownership of the project, including the GitHub repository, Hackage upload rights, and the right to amend this backup maintainers policy passes to Shane O'Brien (@duairc).

  • If Tom Ellis is unavailable or unresponsive to maintenance requests for six months, and this policy has not been changed to the contrary, then full ownership of the project, including the GitHub repository, Hackage upload rights, and the right to amend this backup maintainers policy passes to Ellie Hermaszewska (@expipiplus1).

Contributors

The Opaleye Project was founded by Tom Ellis, inspired by theoretical work on databases by David Spivak. Much of the implementation was based on ideas and code from the HaskellDB project by Daan Leijen, Conny Andersson, Martin Andersson, Mary Bergman, Victor Blomqvist, Bjorn Bringert, Anders Hockersten, Torbjorn Martin, Jeremy Shaw and Justin Bailey.

The following individuals and organisations made helpful contributions which were important in helping to get the project off the ground.

  • Silk (Erik Hesselink, Adam Bergmark)
  • Karamaan (Christopher Lewis)
  • Fynder (Renzo Carbonara, Oliver Charles)
  • Daniel Patterson
  • Jakub Ryška
  • Travis Staton

Joseph Abrahamson, Alfredo Di Napoli and Mietek Bak performed useful reviews of early versions which helped improve the codebase. Since then there have been helpful contributions from many others. Thanks to them all for their help.