warnings, more tidying up

This commit is contained in:
parsonsmatt 2020-10-29 07:43:05 -06:00
parent 17b0da892f
commit 34ae916bf6
6 changed files with 182 additions and 176 deletions

View File

@ -23,152 +23,160 @@ extra-source-files:
changelog.md changelog.md
source-repository head source-repository head
type: git type: git
location: git://github.com/bitemyapp/esqueleto.git location: git://github.com/bitemyapp/esqueleto.git
library library
exposed-modules: exposed-modules:
Database.Esqueleto Database.Esqueleto
Database.Esqueleto.Experimental Database.Esqueleto.Experimental
Database.Esqueleto.Internal.Language Database.Esqueleto.Internal.Language
Database.Esqueleto.Internal.Sql Database.Esqueleto.Internal.Sql
Database.Esqueleto.Internal.Internal Database.Esqueleto.Internal.Internal
Database.Esqueleto.Internal.ExprParser Database.Esqueleto.Internal.ExprParser
Database.Esqueleto.MySQL Database.Esqueleto.MySQL
Database.Esqueleto.PostgreSQL Database.Esqueleto.PostgreSQL
Database.Esqueleto.PostgreSQL.JSON Database.Esqueleto.PostgreSQL.JSON
Database.Esqueleto.SQLite Database.Esqueleto.SQLite
other-modules: other-modules:
Database.Esqueleto.Internal.PersistentImport Database.Esqueleto.Internal.PersistentImport
Database.Esqueleto.PostgreSQL.JSON.Instances Database.Esqueleto.PostgreSQL.JSON.Instances
Paths_esqueleto Paths_esqueleto
hs-source-dirs: hs-source-dirs:
src/ src/
build-depends: build-depends:
base >=4.8 && <5.0 base >=4.8 && <5.0
, aeson >=1.0 , aeson >=1.0
, attoparsec >= 0.13 && < 0.14 , attoparsec >= 0.13 && < 0.14
, blaze-html , blaze-html
, bytestring , bytestring
, conduit >=1.3 , conduit >=1.3
, containers , containers
, monad-logger , monad-logger
, persistent >=2.10.0 && <2.11 , persistent >=2.10.0 && <2.11
, resourcet >=1.2 , resourcet >=1.2
, tagged >=0.2 , tagged >=0.2
, text >=0.11 && <1.3 , text >=0.11 && <1.3
, time >=1.5.0.1 && <=1.10 , time >=1.5.0.1 && <=1.10
, transformers >=0.2 , transformers >=0.2
, unliftio , unliftio
, unordered-containers >=0.2 , unordered-containers >=0.2
if impl(ghc >=8.0) ghc-options:
ghc-options: -Wall -Wno-redundant-constraints -Wall
else -Wno-redundant-constraints
ghc-options: -Wall -Wincomplete-uni-patterns
default-language: Haskell2010 -Wincomplete-record-updates
-Wpartial-fields
-Wmissing-home-modules
-Widentities
-Wredundant-constraints
-Wcpp-undef
-Wcpp-undef
-Wmonomorphism-restriction
default-language: Haskell2010
test-suite mysql test-suite mysql
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: MySQL/Test.hs main-is: MySQL/Test.hs
other-modules: other-modules:
Common.Test Common.Test
Paths_esqueleto Paths_esqueleto
hs-source-dirs: hs-source-dirs:
test test
ghc-options: -Wall ghc-options: -Wall
build-depends: build-depends:
base >=4.8 && <5.0 base >=4.8 && <5.0
, attoparsec , attoparsec
, blaze-html , blaze-html
, bytestring , bytestring
, conduit >=1.3 , conduit >=1.3
, containers , containers
, esqueleto , esqueleto
, exceptions , exceptions
, hspec , hspec
, monad-logger , monad-logger
, mtl , mtl
, mysql , mysql
, mysql-simple , mysql-simple
, persistent >=2.8.0 && <2.11 , persistent >=2.8.0 && <2.11
, persistent-mysql , persistent-mysql
, persistent-template , persistent-template
, resourcet >=1.2 , resourcet >=1.2
, tagged >=0.2 , tagged >=0.2
, text >=0.11 && <1.3 , text >=0.11 && <1.3
, time , time
, transformers >=0.2 , transformers >=0.2
, unliftio , unliftio
, unordered-containers >=0.2 , unordered-containers >=0.2
default-language: Haskell2010 default-language: Haskell2010
test-suite postgresql test-suite postgresql
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: PostgreSQL/Test.hs main-is: PostgreSQL/Test.hs
other-modules: other-modules:
Common.Test Common.Test
PostgreSQL.MigrateJSON PostgreSQL.MigrateJSON
Paths_esqueleto Paths_esqueleto
hs-source-dirs: hs-source-dirs:
test test
ghc-options: -Wall ghc-options: -Wall
build-depends: build-depends:
base >=4.8 && <5.0 base >=4.8 && <5.0
, aeson , aeson
, attoparsec , attoparsec
, blaze-html , blaze-html
, bytestring , bytestring
, conduit >=1.3 , conduit >=1.3
, containers , containers
, esqueleto , esqueleto
, exceptions , exceptions
, hspec , hspec
, monad-logger , monad-logger
, mtl , mtl
, persistent >=2.10.0 && <2.11 , persistent >=2.10.0 && <2.11
, persistent-postgresql >= 2.10.0 && <2.11 , persistent-postgresql >= 2.10.0 && <2.11
, persistent-template , persistent-template
, postgresql-libpq , postgresql-libpq
, postgresql-simple , postgresql-simple
, resourcet >=1.2 , resourcet >=1.2
, tagged >=0.2 , tagged >=0.2
, text >=0.11 && <1.3 , text >=0.11 && <1.3
, time , time
, transformers >=0.2 , transformers >=0.2
, unliftio , unliftio
, unordered-containers >=0.2 , unordered-containers >=0.2
, vector , vector
default-language: Haskell2010 default-language: Haskell2010
test-suite sqlite test-suite sqlite
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: SQLite/Test.hs main-is: SQLite/Test.hs
other-modules: other-modules:
Common.Test Common.Test
Paths_esqueleto Paths_esqueleto
hs-source-dirs: hs-source-dirs:
test test
ghc-options: -Wall ghc-options: -Wall
build-depends: build-depends:
base >=4.8 && <5.0 base >=4.8 && <5.0
, attoparsec , attoparsec
, blaze-html , blaze-html
, bytestring , bytestring
, conduit >=1.3 , conduit >=1.3
, containers , containers
, esqueleto , esqueleto
, exceptions , exceptions
, hspec , hspec
, monad-logger , monad-logger
, mtl , mtl
, persistent >=2.8.0 && <2.11 , persistent >=2.8.0 && <2.11
, persistent-sqlite , persistent-sqlite
, persistent-template , persistent-template
, resourcet >=1.2 , resourcet >=1.2
, tagged >=0.2 , tagged >=0.2
, text >=0.11 && <1.3 , text >=0.11 && <1.3
, time , time
, transformers >=0.2 , transformers >=0.2
, unliftio , unliftio
, unordered-containers >=0.2 , unordered-containers >=0.2
default-language: Haskell2010 default-language: Haskell2010

View File

@ -560,10 +560,23 @@ e ^. field
case e of case e of
EEntity ident -> ident EEntity ident -> ident
EAliasedEntity baseI _ -> baseI EAliasedEntity baseI _ -> baseI
EAliasedEntityReference a b ->
error $ unwords
[ "Used (^.) with an EAliasedEntityReference."
, "Please file this as an Esqueleto bug."
, "EAliasedEntityReference", show a, show b
]
fieldIdent = fieldIdent =
case e of case e of
EEntity _ -> fromDBName info (fieldDB fieldDef) EEntity _ -> fromDBName info (fieldDB fieldDef)
EAliasedEntity baseI _ -> useIdent info $ aliasedEntityColumnIdent baseI fieldDef EAliasedEntity baseI _ -> useIdent info $ aliasedEntityColumnIdent baseI fieldDef
EAliasedEntityReference a b ->
error $ unwords
[ "Used (^.) with an EAliasedEntityReference."
, "Please file this as an Esqueleto bug."
, "EAliasedEntityReference", show a, show b
]
-- | Project an SqlExpression that may be null, guarding against null cases. -- | Project an SqlExpression that may be null, guarding against null cases.
withNonNull withNonNull

View File

@ -7,9 +7,8 @@ module Database.Esqueleto.MySQL
( random_ ( random_
) where ) where
import Database.Esqueleto.Internal.Language hiding (random_) import Database.Esqueleto.Internal.Internal hiding (random_)
import Database.Esqueleto.Internal.PersistentImport import Database.Esqueleto.Internal.PersistentImport
import Database.Esqueleto.Internal.Sql
-- | (@random()@) Split out into database specific modules -- | (@random()@) Split out into database specific modules
-- because MySQL uses `rand()`. -- because MySQL uses `rand()`.

View File

@ -43,22 +43,8 @@ import Data.List.NonEmpty (NonEmpty((:|)))
import Data.Proxy (Proxy(..)) import Data.Proxy (Proxy(..))
import qualified Data.Text.Internal.Builder as TLB import qualified Data.Text.Internal.Builder as TLB
import Data.Time.Clock (UTCTime) import Data.Time.Clock (UTCTime)
import Database.Esqueleto.Internal.Internal import Database.Esqueleto.Internal.Internal hiding (random_)
( CompositeKeyError(..)
, EsqueletoError(..)
, FinalResult(..)
, Ident(..)
, KnowResult
, SetClause
, UnexpectedCaseError(..)
, UnexpectedValueError(..)
, renderUpdates
, toUniqueDef
, uncommas
)
import Database.Esqueleto.Internal.Language hiding (random_)
import Database.Esqueleto.Internal.PersistentImport hiding (upsert, upsertBy) import Database.Esqueleto.Internal.PersistentImport hiding (upsert, upsertBy)
import Database.Esqueleto.Internal.Sql
import Database.Persist.Class (OnlyOneUniqueKey) import Database.Persist.Class (OnlyOneUniqueKey)
-- | (@random()@) Split out into database specific modules -- | (@random()@) Split out into database specific modules

View File

@ -1,14 +1,14 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
-- | This module contain SQLite-specific functions. -- | This module contain SQLite-specific functions.
-- --
-- /Since: 2.2.8/ -- @since 2.2.8
module Database.Esqueleto.SQLite module Database.Esqueleto.SQLite
( random_ ( random_
) where ) where
import Database.Esqueleto.Internal.Language hiding (random_) import Database.Esqueleto.Internal.Internal hiding (random_)
import Database.Esqueleto.Internal.PersistentImport import Database.Esqueleto.Internal.PersistentImport
import Database.Esqueleto.Internal.Sql
-- | (@random()@) Split out into database specific modules -- | (@random()@) Split out into database specific modules
-- because MySQL uses `rand()`. -- because MySQL uses `rand()`.

View File

@ -1865,21 +1865,21 @@ testRenderSql run = do
expr `shouldBe` "? = ?" expr `shouldBe` "? = ?"
describe "EEntity Ident behavior" $ do describe "EEntity Ident behavior" $ do
let let render :: SqlExpr (Entity val) -> Text.Text
render :: SqlExpr (Entity val) -> Text.Text render (EI.EEntity (EI.I ident)) = ident
render (EI.EEntity (EI.I ident)) = ident render _ = error "guess we gotta handle this in the test suite now"
it "renders sensibly" $ do it "renders sensibly" $ run $ do
results <- run $ do _ <- insert $ Foo 2
_ <- insert $ Foo 2 _ <- insert $ Foo 3
_ <- insert $ Foo 3 _ <- insert $ Person "hello" Nothing Nothing 3
_ <- insert $ Person "hello" Nothing Nothing 3 results <- select $
select $ from $ \(a `LeftOuterJoin` b) -> do
from $ \(a `LeftOuterJoin` b) -> do on $ a ^. FooName ==. b ^. PersonFavNum
on $ a ^. FooName ==. b ^. PersonFavNum pure (val (render a), val (render b))
pure (val (render a), val (render b)) liftIO $
head results head results
`shouldBe` `shouldBe`
(Value "Foo", Value "Person") (Value "Foo", Value "Person")
describe "ExprParser" $ do describe "ExprParser" $ do
let parse parser = AP.parseOnly (parser '#') let parse parser = AP.parseOnly (parser '#')