use stack 8.10 by default, support pers2.13

This commit is contained in:
parsonsmatt 2021-04-09 08:39:57 -06:00
parent 7a0649e449
commit ed61e90cf0
6 changed files with 13 additions and 12 deletions

View File

@ -13,8 +13,7 @@ extra-source-files:
dependencies:
- base
- esqueleto
- persistent
- persistent-template
- persistent >= 2.12
- persistent-postgresql
- mtl
- monad-logger

View File

@ -16,6 +16,7 @@ import qualified Data.Set as Set
import Data.Text (Text)
import qualified Data.Text as Text
import Database.Persist.Sql
import Database.Persist.SqlBackend
-- | A type representing the access of a table value. In Esqueleto, we get
-- a guarantee that the access will look something like:
@ -43,7 +44,7 @@ parseOnExpr sqlBackend text = do
-- with postgresql, mysql, and sqlite backends.
mkEscapeChar :: SqlBackend -> Either String Char
mkEscapeChar sqlBackend =
case Text.uncons (connEscapeRawName sqlBackend "") of
case Text.uncons (getEscapedRawName "" sqlBackend) of
Nothing ->
Left "Failed to get an escape character from the SQL backend."
Just (c, _) ->
@ -63,9 +64,9 @@ skipToEscape escapeChar = void (takeWhile (/= escapeChar))
parseEscapedIdentifier :: ExprParser [Char]
parseEscapedIdentifier escapeChar = do
char escapeChar
_ <- char escapeChar
str <- parseEscapedChars escapeChar
char escapeChar
_ <- char escapeChar
pure str
parseTableAccess :: ExprParser TableAccess

View File

@ -55,6 +55,7 @@ import qualified Data.Text.Lazy.Builder as TLB
import Data.Typeable (Typeable)
import Database.Esqueleto.Internal.ExprParser (TableAccess(..), parseOnExpr)
import Database.Esqueleto.Internal.PersistentImport
import Database.Persist.SqlBackend
import qualified Database.Persist
import Database.Persist (FieldNameDB(..), EntityNameDB(..))
import Database.Persist.Sql.Util
@ -1809,7 +1810,7 @@ instance Show FromClause where
"(FromIdent " <> show ident <> ")"
where
dummy = SqlBackend
dummy = mkSqlBackend MkSqlBackendArgs
{ connEscapeRawName = id
}
render' = T.unpack . renderExpr dummy
@ -2145,7 +2146,7 @@ sub :: PersistField a => Mode -> SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value
sub mode query = ERaw Parens $ \info -> toRawSql mode info query
fromDBName :: IdentInfo -> DBName -> TLB.Builder
fromDBName (conn, _) = TLB.fromText . connEscapeRawName conn . unDBName
fromDBName (conn, _) = TLB.fromText . flip getEscapedRawName conn . unDBName
existsHelper :: SqlQuery () -> SqlExpr (Value Bool)
existsHelper = sub SELECT . (>> return true)
@ -3010,8 +3011,7 @@ makeOrderBy info is =
makeLimit :: IdentInfo -> LimitClause -> [OrderByClause] -> (TLB.Builder, [PersistValue])
makeLimit (conn, _) (Limit ml mo) orderByClauses =
let limitRaw = connLimitOffset conn (v ml, v mo) hasOrderClause "\n"
hasOrderClause = not (null orderByClauses)
let limitRaw = getConnLimitOffset (v ml, v mo) "\n" conn
v = maybe 0 fromIntegral
in (TLB.fromText limitRaw, mempty)

View File

@ -48,6 +48,7 @@ import Database.Esqueleto.Internal.Internal hiding (random_)
import Database.Esqueleto.Internal.PersistentImport hiding (upsert, upsertBy)
import Database.Persist.Class (OnlyOneUniqueKey)
import Database.Persist (ConstraintNameDB(..), EntityNameDB(..))
import Database.Persist.SqlBackend
-- | (@random()@) Split out into database specific modules
-- because MySQL uses `rand()`.
@ -207,7 +208,7 @@ upsertBy
-- ^ the record in the database after the operation
upsertBy uniqueKey record updates = do
sqlB <- R.ask
case connUpsertSql sqlB of
case getConnUpsertSql sqlB of
Nothing ->
-- Postgres backend should have connUpsertSql, if this error is
-- thrown, check changes on persistent

View File

@ -6,7 +6,7 @@ packages:
extra-deps:
- git: git@github.com:yesodweb/persistent
commit: 3e2975d7110b5330f987e1ceef747c43d0c6e0a9
commit: f7ad9b05a1ee899c6800962cbc795b39d01c5643
subdirs:
- persistent
- persistent-sqlite

View File

@ -1 +1 @@
stack-8.8.yaml
stack-8.10.yaml