Merge pull request #69 from circuithub/exists

Bump Opaleye dependency to 0.7.2.0 to take advantage of new EXISTS support
This commit is contained in:
Shane 2021-06-22 12:51:40 +01:00 committed by GitHub
commit f36d7d03dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 10 deletions

View File

@ -5,10 +5,10 @@
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "5b5a18e442df6e27ad8549d69b8868b62adb08c3",
"sha256": "055mk7kmjppng66ppnb8kr96v4wwc8pcxfsls5gl77129hsz9aph",
"rev": "e7bb8ab2921a11a1d014c70a87898f73e086594d",
"sha256": "17c0xqzwnchcy71p8372cydcxc7qf0i8x12d0lf6p1g8yd4al6fa",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/5b5a18e442df6e27ad8549d69b8868b62adb08c3.tar.gz",
"url": "https://github.com/input-output-hk/haskell.nix/archive/e7bb8ab2921a11a1d014c70a87898f73e086594d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {

View File

@ -25,7 +25,7 @@ library
, case-insensitive
, contravariant
, hasql ^>= 1.4.5.1
, opaleye ^>= 0.7.1.0
, opaleye ^>= 0.7.2.0
, profunctors
, scientific
, semialign

View File

@ -11,23 +11,21 @@ where
import Prelude hiding ( filter )
-- opaleye
import qualified Opaleye.Operators as Opaleye
import qualified Opaleye.Exists as Opaleye
import qualified Opaleye.Operators as Opaleye hiding ( exists )
-- rel8
import Rel8.Expr ( Expr )
import Rel8.Expr.Opaleye ( fromColumn, fromPrimExpr )
import Rel8.Query ( Query )
import Rel8.Query.Filter ( filter )
import Rel8.Query.Maybe ( optional )
import Rel8.Query.Opaleye ( mapOpaleye )
import Rel8.Table.Eq ( EqTable, (==:) )
import Rel8.Table.Maybe ( isJustTable )
-- | Checks if a query returns at least one row.
exists :: Query a -> Query (Expr Bool)
exists = fmap isJustTable . optional . present
-- FIXME: change this when b7aacc07c6392654cae439fc3b997620c3aa7a87 makes it
-- into a release of Opaleye
exists = fmap (fromPrimExpr . fromColumn) . mapOpaleye Opaleye.exists
inQuery :: EqTable a => a -> Query a -> Query (Expr Bool)