From d55a4adf0a223302669b6aa2d45b2deae7146e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20Sch=C3=B6ttl?= Date: Fri, 21 Oct 2022 23:02:24 +0200 Subject: [PATCH 1/2] Use getEscapedRawName instead of internalized connEscapeName --- test/TestImport.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/TestImport.hs b/test/TestImport.hs index e467891..0694dcb 100644 --- a/test/TestImport.hs +++ b/test/TestImport.hs @@ -9,7 +9,8 @@ module TestImport import Application (makeFoundation, makeLogWare) import ClassyPrelude as X hiding (delete, deleteBy, Handler) import Database.Persist as X hiding (get) -import Database.Persist.Sql (SqlPersistM, runSqlPersistMPool, rawExecute, rawSql, unSingle, connEscapeName) +import Database.Persist.Sql (SqlPersistM, runSqlPersistMPool, rawExecute, rawSql, unSingle) +import Database.Persist.SqlBackend (getEscapedRawName) import Foundation as X import Model as X import Test.Hspec as X @@ -56,7 +57,7 @@ wipeDB app = runDBWithApp app $ do -- Should your application grow to hundreds of tables and tests, -- switching to DELETE could be a substantial speedup. -- See: https://github.com/yesodweb/yesod-scaffold/issues/201 - let escapedTables = map (connEscapeName sqlBackend . DBName) tables + let escapedTables = map (getEscapedRawName sqlBackend) tables query = "TRUNCATE TABLE " ++ intercalate ", " escapedTables rawExecute query [] From eb8182381725e4ed0a1e88535c3d874ad49d60ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20Sch=C3=B6ttl?= Date: Sun, 23 Oct 2022 11:35:45 +0200 Subject: [PATCH 2/2] Fixes to get tests working --- package.yaml | 16 ++++++++-------- src/Model.hs | 7 ++++--- test/TestImport.hs | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package.yaml b/package.yaml index 16b6110..1d21d0b 100644 --- a/package.yaml +++ b/package.yaml @@ -8,31 +8,31 @@ dependencies: - yesod-core >=1.6 && <1.7 - yesod-auth >=1.6 && <1.7 - yesod-static >=1.6 && <1.7 -- yesod-form >=1.6 && <1.7 +- yesod-form >=1.6 && <1.8 - classy-prelude >=1.5 && <1.6 - classy-prelude-conduit >=1.5 && <1.6 - classy-prelude-yesod >=1.5 && <1.6 - bytestring >=0.10 && <0.11 - text >=0.11 && <2.0 -- persistent >=2.9 && <2.11 -- persistent-postgresql >=2.9 && <2.11 -- persistent-template >=2.5 && <2.9 +- persistent >=2.9 && <2.14 +- persistent-postgresql >=2.13 && <2.14 +- persistent-template >=2.5 && <2.14 - template-haskell - shakespeare >=2.0 && <2.1 - hjsmin >=0.1 && <0.3 - monad-control >=0.3 && <1.1 -- wai-extra >=3.0 && <3.1 +- wai-extra >=3.0 && <3.2 - yaml >=0.11 && <0.12 - http-client-tls >=0.3 && <0.4 - http-conduit >=2.3 && <2.4 - directory >=1.1 && <1.4 - warp >=3.0 && <3.4 - data-default -- aeson >=1.4 && <1.5 +- aeson >=1.4 && <2.1 - conduit >=1.0 && <2.0 - monad-logger >=0.3 && <0.4 -- fast-logger >=2.2 && <3.1 -- wai-logger >=2.2 && <2.4 +- fast-logger >=2.2 && <3.2 +- wai-logger >=2.2 && <2.5 - file-embed - safe - unordered-containers diff --git a/src/Model.hs b/src/Model.hs index aefb5b5..b8b07b9 100644 --- a/src/Model.hs +++ b/src/Model.hs @@ -7,9 +7,10 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE DataKinds #-} module Model where import ClassyPrelude.Yesod diff --git a/test/TestImport.hs b/test/TestImport.hs index 0694dcb..2b8aa7e 100644 --- a/test/TestImport.hs +++ b/test/TestImport.hs @@ -57,7 +57,7 @@ wipeDB app = runDBWithApp app $ do -- Should your application grow to hundreds of tables and tests, -- switching to DELETE could be a substantial speedup. -- See: https://github.com/yesodweb/yesod-scaffold/issues/201 - let escapedTables = map (getEscapedRawName sqlBackend) tables + let escapedTables = map (\t -> getEscapedRawName t sqlBackend) tables query = "TRUNCATE TABLE " ++ intercalate ", " escapedTables rawExecute query []