Skip to content

Commit

Permalink
Rename delete to deleteRecordById
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Hamilton committed Dec 2, 2020
1 parent 11639d3 commit 103ad5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions IHP/ModelSupport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module IHP.ModelSupport
import IHP.HaskellSupport
import IHP.NameSupport
import qualified Prelude
import ClassyPrelude hiding (UTCTime, find, ModifiedJulianDay, delete)
import ClassyPrelude hiding (UTCTime, find, ModifiedJulianDay)
import qualified ClassyPrelude
import Database.PostgreSQL.Simple (Connection)
import qualified Text.Inflections
Expand Down Expand Up @@ -342,7 +342,7 @@ logQuery query parameters = when queryDebuggingEnabled (putStrLn (tshow (query,
--
-- Use 'deleteRecords' if you want to delete multiple records.
deleteRecord :: forall model id. (?modelContext :: ModelContext, Show id, KnownSymbol (GetTableName model), HasField "id" model id, ToField id) => model -> IO ()
deleteRecord model = get #id model |> delete @model @id
deleteRecord model = get #id model |> deleteRecordById @model @id

{-# INLINE deleteRecord #-}

Expand All @@ -352,14 +352,14 @@ deleteRecord model = get #id model |> delete @model @id
-- >>> delete projectId
-- DELETE FROM projects WHERE id = '..'
--
delete :: forall model id. (?modelContext :: ModelContext, Show id, KnownSymbol (GetTableName model), HasField "id" model id, ToField id) => id -> IO ()
delete id = do
deleteRecordById :: forall model id. (?modelContext :: ModelContext, Show id, KnownSymbol (GetTableName model), HasField "id" model id, ToField id) => id -> IO ()
deleteRecordById id = do
let theQuery = "DELETE FROM " <> tableName @model <> " WHERE id = ?"
let theParameters = (PG.Only id)
logQuery theQuery theParameters
sqlExec (PG.Query . cs $! theQuery) theParameters
pure ()
{-# INLINE delete #-}
{-# INLINE deleteRecordById #-}

-- | Runs a @DELETE@ query for a list of records.
--
Expand Down
2 changes: 1 addition & 1 deletion IHP/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import qualified Prelude
import qualified Data.Text as Text
import Data.Proxy (Proxy (Proxy))
import Control.Monad (when, unless, mapM, mapM_, forM, forM_, sequence, sequence_, join, forever)
import Data.List hiding (head, last, unwords, unlines, words, lines, isPrefixOf, isSuffixOf, isInfixOf, intercalate, intersperse, (++), splitAt, null, delete)
import Data.List hiding (head, last, unwords, unlines, words, lines, isPrefixOf, isSuffixOf, isInfixOf, intercalate, intersperse, (++), splitAt, null)
import qualified Data.List as List
import Data.String.Conversions (ConvertibleStrings (convertString), cs)
import Data.Time.Clock
Expand Down

0 comments on commit 103ad5b

Please sign in to comment.