From cfde5932fd275c2fc329fab336f0f7809c9e2d00 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Sat, 28 Dec 2024 10:33:22 +0000 Subject: [PATCH] agent: restore methods for backwards compatibility with simplex-chat --- src/Simplex/Messaging/Agent/Store/SQLite/DB.hs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Simplex/Messaging/Agent/Store/SQLite/DB.hs b/src/Simplex/Messaging/Agent/Store/SQLite/DB.hs index 7e8406d5c..46c0847d1 100644 --- a/src/Simplex/Messaging/Agent/Store/SQLite/DB.hs +++ b/src/Simplex/Messaging/Agent/Store/SQLite/DB.hs @@ -16,8 +16,10 @@ module Simplex.Messaging.Agent.Store.SQLite.DB execute, execute_, executeMany, + executeNamed, query, query_, + queryNamed, ) where @@ -31,7 +33,7 @@ import Data.Map.Strict (Map) import qualified Data.Map.Strict as M import Data.Text (Text) import Data.Time (diffUTCTime, getCurrentTime) -import Database.SQLite.Simple (FromRow, Query, ToRow) +import Database.SQLite.Simple (FromRow, NamedParam, Query, ToRow) import qualified Database.SQLite.Simple as SQL import Database.SQLite.Simple.FromField (FromField (..)) import Database.SQLite.Simple.ToField (ToField (..)) @@ -103,6 +105,11 @@ execute_ :: Connection -> Query -> IO () execute_ Connection {conn, slow} sql = timeIt slow sql $ SQL.execute_ conn sql {-# INLINE execute_ #-} +-- TODO [postgres] remove +executeNamed :: Connection -> Query -> [NamedParam] -> IO () +executeNamed Connection {conn, slow} sql = timeIt slow sql . SQL.executeNamed conn sql +{-# INLINE executeNamed #-} + executeMany :: ToRow q => Connection -> Query -> [q] -> IO () executeMany Connection {conn, slow} sql = timeIt slow sql . SQL.executeMany conn sql {-# INLINE executeMany #-} @@ -115,4 +122,9 @@ query_ :: FromRow r => Connection -> Query -> IO [r] query_ Connection {conn, slow} sql = timeIt slow sql $ SQL.query_ conn sql {-# INLINE query_ #-} +-- TODO [postgres] remove +queryNamed :: FromRow r => Connection -> Query -> [NamedParam] -> IO [r] +queryNamed Connection {conn, slow} sql = timeIt slow sql . SQL.queryNamed conn sql +{-# INLINE queryNamed #-} + $(J.deriveJSON defaultJSON ''SlowQueryStats)