From: Michael Orlitzky Date: Sun, 20 Apr 2014 22:29:28 +0000 (-0400) Subject: Replace all raw DELETE queries with deleteAll. X-Git-Tag: 0.0.5~4 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=fa27649ae583f6bdc20c54db4fc8f38a382a536c;p=dead%2Fhtsn-import.git Replace all raw DELETE queries with deleteAll. Set a new lower bound on groundhog for the deleteAll function. --- diff --git a/doc/TODO b/doc/TODO index 4f22e0c..ade3c5c 100644 --- a/doc/TODO +++ b/doc/TODO @@ -20,4 +20,3 @@ 6. Replace boilerplate with regular-xmlpickler. -7. Replace inline SQL queries with deleteAll. diff --git a/htsn-import.cabal b/htsn-import.cabal index b792247..a38aa34 100644 --- a/htsn-import.cabal +++ b/htsn-import.cabal @@ -81,7 +81,8 @@ executable htsn-import hslogger == 1.2.*, htsn-common == 0.0.1, hxt == 9.3.*, - groundhog == 0.4.*, + -- deleteAll showed up in 0.4.1 + groundhog >= 0.4.1, groundhog-postgresql == 0.4.*, groundhog-sqlite == 0.4.*, groundhog-th == 0.4.*, diff --git a/src/TSN/XML/AutoRacingSchedule.hs b/src/TSN/XML/AutoRacingSchedule.hs index ab1c29e..aeb8745 100644 --- a/src/TSN/XML/AutoRacingSchedule.hs +++ b/src/TSN/XML/AutoRacingSchedule.hs @@ -29,7 +29,7 @@ import Data.Time ( UTCTime(..) ) import Data.Tuple.Curry ( uncurryN ) import Database.Groundhog ( countAll, - executeRaw, + deleteAll, migrate, runMigration, silentMigrationLogger ) @@ -555,8 +555,7 @@ test_on_delete_cascade = testGroup "cascading delete tests" migrate b migrate c _ <- dbimport sched - -- No idea how 'delete' works, so do this instead. - executeRaw False "DELETE FROM auto_racing_schedules;" [] + deleteAll a count_a <- countAll a count_b <- countAll b count_c <- countAll c diff --git a/src/TSN/XML/Injuries.hs b/src/TSN/XML/Injuries.hs index af1bc37..6ae9118 100644 --- a/src/TSN/XML/Injuries.hs +++ b/src/TSN/XML/Injuries.hs @@ -32,7 +32,7 @@ import Data.Time ( UTCTime ) import Data.Typeable ( Typeable ) import Database.Groundhog ( countAll, - executeRaw, + deleteAll, migrate, runMigration, silentMigrationLogger ) @@ -346,8 +346,7 @@ test_on_delete_cascade = migrate a migrate b _ <- dbimport inj - -- No idea how 'delete' works, so do this instead. - executeRaw False "DELETE FROM injuries;" [] + deleteAll a count_a <- countAll a count_b <- countAll b return $ count_a + count_b diff --git a/src/TSN/XML/InjuriesDetail.hs b/src/TSN/XML/InjuriesDetail.hs index 4356eb6..fbb938e 100644 --- a/src/TSN/XML/InjuriesDetail.hs +++ b/src/TSN/XML/InjuriesDetail.hs @@ -30,7 +30,7 @@ import Data.Tuple.Curry ( uncurryN ) import Database.Groundhog ( DefaultKey, countAll, - executeRaw, + deleteAll, migrate, runMigration, silentMigrationLogger ) @@ -463,8 +463,7 @@ test_on_delete_cascade = testGroup "cascading delete tests" migrate b migrate c _ <- dbimport inj - -- No idea how 'delete' works, so do this instead. - executeRaw False "DELETE FROM injuries_detail;" [] + deleteAll a count_a <- countAll a count_b <- countAll b count_c <- countAll c diff --git a/src/TSN/XML/News.hs b/src/TSN/XML/News.hs index 49be37e..c42b931 100644 --- a/src/TSN/XML/News.hs +++ b/src/TSN/XML/News.hs @@ -31,7 +31,7 @@ import Data.Tuple.Curry ( uncurryN ) import Data.Typeable ( Typeable ) import Database.Groundhog ( countAll, - executeRaw, + deleteAll, insert_, migrate, runMigration, @@ -530,8 +530,7 @@ test_on_delete_cascade = testGroup "cascading delete tests" migrate d migrate e _ <- dbimport news - -- No idea how 'delete' works, so do this instead. - executeRaw False "DELETE FROM news;" [] + deleteAll a count_a <- countAll a count_b <- countAll b count_c <- countAll c diff --git a/src/TSN/XML/Odds.hs b/src/TSN/XML/Odds.hs index 52b7b9f..b8888af 100644 --- a/src/TSN/XML/Odds.hs +++ b/src/TSN/XML/Odds.hs @@ -33,7 +33,7 @@ import Database.Groundhog ( (=.), (==.), countAll, - executeRaw, + deleteAll, insert_, migrate, runMigration, @@ -837,8 +837,7 @@ test_on_delete_cascade = testGroup "cascading delete tests" migrate e migrate f _ <- dbimport odds - -- No idea how 'delete' works, so do this instead. - executeRaw False "DELETE FROM odds;" [] + deleteAll a count_a <- countAll a count_b <- countAll b count_c <- countAll c diff --git a/src/TSN/XML/Scores.hs b/src/TSN/XML/Scores.hs index 6044fe7..571f6b3 100644 --- a/src/TSN/XML/Scores.hs +++ b/src/TSN/XML/Scores.hs @@ -30,7 +30,7 @@ import Data.Tuple.Curry ( uncurryN ) import Data.Typeable ( Typeable ) import Database.Groundhog ( countAll, - executeRaw, + deleteAll, insert, insert_, migrate, @@ -618,7 +618,7 @@ test_on_delete_cascade = testGroup "cascading delete tests" migrate f _ <- dbimport score -- No idea how 'delete' works, so do this instead. - executeRaw False "DELETE FROM scores;" [] + deleteAll a count_a <- countAll a count_b <- countAll b count_c <- countAll c diff --git a/src/TSN/XML/Weather.hs b/src/TSN/XML/Weather.hs index 03bb83d..bda29ee 100644 --- a/src/TSN/XML/Weather.hs +++ b/src/TSN/XML/Weather.hs @@ -26,7 +26,7 @@ import Data.Time ( UTCTime ) import Data.Tuple.Curry ( uncurryN ) import Database.Groundhog ( countAll, - executeRaw, + deleteAll, migrate, runMigration, silentMigrationLogger ) @@ -412,8 +412,7 @@ test_on_delete_cascade = migrate b migrate c _ <- dbimport weather - -- No idea how 'delete' works, so do this instead. - executeRaw False "DELETE FROM weather;" [] + deleteAll a count_a <- countAll a count_b <- countAll b count_c <- countAll c