module Unison.Sqlite.Connection.Internal
  ( Connection (..),
  )
where

import Data.Map (Map)
import Data.Text (Text)
import Database.SQLite.Simple qualified as Sqlite
import UnliftIO.STM (TVar)

-- | A /non-thread safe/ connection to a SQLite database.
data Connection = Connection
  { Connection -> String
name :: String,
    Connection -> String
file :: FilePath,
    Connection -> Connection
conn :: Sqlite.Connection,
    Connection -> TVar (Map Text Statement)
statementCache :: TVar (Map Text Sqlite.Statement)
  }

instance Show Connection where
  show :: Connection -> String
show (Connection String
name String
file Connection
_conn TVar (Map Text Statement)
_statementCache) =
    String
"Connection { name = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
name String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", file = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
file String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" }"