mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-10-22 09:12:17 +00:00
make function processing sql rows module-level (#533)
This commit is contained in:
1 parent
41d3c14157
commit
f8505d4add
1 file changed
+6
-4
@@ -245,12 +245,14 @@ sqlString s = quote <> T.replace quote "''" (T.pack s) <> quote
|
||||
exexSQL :: DB.Connection -> Text -> IO [Text]
|
||||
exexSQL db query = do
|
||||
rs <- newIORef []
|
||||
SQLite3.execWithCallback (DB.connectionHandle db) query (addRow rs)
|
||||
SQLite3.execWithCallback (DB.connectionHandle db) query (addSQLResultRow rs)
|
||||
reverse <$> readIORef rs
|
||||
|
||||
addSQLResultRow :: IORef [Text] -> SQLite3.ColumnIndex -> [Text] -> [Maybe Text] -> IO ()
|
||||
addSQLResultRow rs _count names values = modifyIORef' rs $ \case
|
||||
[] -> [showValues values, T.intercalate "|" names]
|
||||
rs' -> showValues values : rs'
|
||||
where
|
||||
addRow rs _count names values = modifyIORef' rs $ \case
|
||||
[] -> [showValues values, T.intercalate "|" names]
|
||||
rs' -> showValues values : rs'
|
||||
showValues = T.intercalate "|" . map (fromMaybe "")
|
||||
|
||||
checkConstraint :: StoreError -> IO (Either StoreError a) -> IO (Either StoreError a)
|
||||
|
||||
Reference in new issue
Block a user