packages feed

sql-simple 0.3.0 → 0.3.1

raw patch · 4 files changed

+14/−11 lines, 4 filesdep +containersdep −unordered-containers

Dependencies added: containers

Dependencies removed: unordered-containers

Files

Database/Sql/Simple.hs view
@@ -33,7 +33,8 @@     , rollback     , withTransaction     -- * specify backend-    -- | +    -- |+    --     -- @      --  sql (sqlite +:+ postgresql) $ query     -- @
Database/Sql/Simple/Internal.hs view
@@ -25,9 +25,9 @@ import Data.Proxy import Data.Typeable import Data.String-import qualified Data.HashMap.Strict as H+import qualified Data.Map.Strict as M -data Query = Query T.Text (H.HashMap TypeRep T.Text)+data Query = Query T.Text (M.Map TypeRep T.Text)     deriving (Show, Eq)  newtype Sql (l :: [*]) a = Sql { unSql :: IO a }@@ -40,10 +40,10 @@     restoreM = Sql . restoreM . unStMSql  instance IsString Query where-    fromString s = Query (T.pack s) H.empty+    fromString s = Query (T.pack s) M.empty  getQuery :: TypeRep -> Query -> T.Text-getQuery t (Query d h) = H.lookupDefault d t h+getQuery t (Query d h) = maybe d id $ M.lookup t h  newtype Only a = Only { fromOnly :: a } @@ -111,7 +111,7 @@ -- q = specify sqlite \"sqlite query\" \"common query\" -- @ specify :: Backend b => proxy ((b :: *) ': '[]) -> T.Text -> Query -> Query-specify p q (Query t h) = Query t (H.insert (headt p) q h)+specify p q (Query t h) = Query t (M.insert (headt p) q h)   where     headt :: forall proxy a as. Typeable a => proxy ((a :: *) ': as) -> TypeRep     headt _ = typeOf (undefined :: a)
README.md view
@@ -14,6 +14,7 @@ import Database.Sql.Simple import Database.Sql.Simple.SQLite import Database.Sql.Simple.PostgreSQL+import Database.Sql.Simple.Pool  -- you must specify 1st type variable of Sql Monad. -- by explicit type signature,@@ -24,21 +25,22 @@     execute  c "INSERT INTO test VALUES (?)" (Only (1 :: Int))     map fromOnly <$> query_ c "SELECT * FROM test" --- or sql function(testQuery' is equivalent to testQuery).+-- or sql function(testQuery' equivalent to testQuery). testQuery' c = sql (sqlite +:+ postgreSQL) $ do     execute_ c "CREATE TABLE test (id int)"     execute  c "INSERT INTO test VALUES (?)" (Only (1 :: Int))     i <- map fromOnly <$> query_ c "SELECT * FROM test"     return (i :: [Int]) --- you can set backend specific Query.+-- you can specify backend specific Query. specificQuery :: Backend conn => conn -> Sql '[SQLite, PostgreSQL] () specificQuery c =     execute_ c (specify sqlite "[sqlite query]" "[common query]")  main :: IO () main = do-    l <- withConnection ("test.sqlite3" :: ConnectInfo SQLite) testQuery+    -- l <- withConnection ("test.sqlite3" :: ConnectInfo SQLite) testQuery+    l <- withConnection (ConnectionPool def "test.sqlite3" :: ConnectInfo (Pool SQLite)) testQuery     -- l <- withConnection (def :: ConnectInfo PostgreSQL) testQuery     print l ```
sql-simple.cabal view
@@ -1,5 +1,5 @@ name:                sql-simple-version:             0.3.0+version:             0.3.1 synopsis:            common middle-level sql client. description:         please read README.md <https://github.com/philopon/sql-simple/blob/master/README.md> license:             MIT@@ -21,7 +21,7 @@                      , exceptions           >=0.6 && <0.7                      , text                 >=1.1 && <1.2                      , transformers         >=0.4 && <0.5-                     , unordered-containers >=0.2 && <0.3+                     , containers           >=0.5 && <0.6                      , monad-control        >=0.3 && <0.4                      , transformers-base    >=0.4 && <0.5