diff --git a/examples/package.yaml b/examples/package.yaml index 7ccde97..7d3d2ed 100644 --- a/examples/package.yaml +++ b/examples/package.yaml @@ -13,8 +13,7 @@ extra-source-files: dependencies: - base - esqueleto -- persistent -- persistent-template +- persistent >= 2.12 - persistent-postgresql - mtl - monad-logger diff --git a/src/Database/Esqueleto/Internal/ExprParser.hs b/src/Database/Esqueleto/Internal/ExprParser.hs index 25efb9c..be155ef 100644 --- a/src/Database/Esqueleto/Internal/ExprParser.hs +++ b/src/Database/Esqueleto/Internal/ExprParser.hs @@ -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 diff --git a/src/Database/Esqueleto/Internal/Internal.hs b/src/Database/Esqueleto/Internal/Internal.hs index ddfe8aa..d9b9cbf 100644 --- a/src/Database/Esqueleto/Internal/Internal.hs +++ b/src/Database/Esqueleto/Internal/Internal.hs @@ -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) diff --git a/src/Database/Esqueleto/PostgreSQL.hs b/src/Database/Esqueleto/PostgreSQL.hs index bd8685c..ce4ab3a 100644 --- a/src/Database/Esqueleto/PostgreSQL.hs +++ b/src/Database/Esqueleto/PostgreSQL.hs @@ -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 diff --git a/stack-8.10.yaml b/stack-8.10.yaml index b8b8363..22362ec 100644 --- a/stack-8.10.yaml +++ b/stack-8.10.yaml @@ -6,7 +6,7 @@ packages: extra-deps: - git: git@github.com:yesodweb/persistent - commit: 3e2975d7110b5330f987e1ceef747c43d0c6e0a9 + commit: f7ad9b05a1ee899c6800962cbc795b39d01c5643 subdirs: - persistent - persistent-sqlite diff --git a/stack.yaml b/stack.yaml index 413602c..1b47194 120000 --- a/stack.yaml +++ b/stack.yaml @@ -1 +1 @@ -stack-8.8.yaml \ No newline at end of file +stack-8.10.yaml \ No newline at end of file