packages feed

simplest-sqlite 0.1.0.3 → 0.1.0.4

raw patch · 2 files changed

+13/−2 lines, 2 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Database.SmplstSQLite3: instance Database.SmplstSQLite3.SQLiteData a => Database.SmplstSQLite3.SQLiteData (GHC.Internal.Maybe.Maybe a)

Files

simplest-sqlite.cabal view
@@ -2,7 +2,7 @@ cabal-version: >= 1.10  name: simplest-sqlite-version: 0.1.0.3+version: 0.1.0.4 stability: Experimental author: YoshikuniJujo <PAF01143@nifty.ne.jp> maintainer: YoshikuniJujo <PAF01143@nifty.ne.jp>
src/Database/SmplstSQLite3.hs view
@@ -113,6 +113,13 @@ 	bindN :: Stmt -> Int -> a -> IO () 	column :: Stmt -> Int -> IO a +instance SQLiteData a => SQLiteData (Maybe a) where+	bindN stmt i Nothing = sqlite3BindNull stmt i ()+	bindN stmt i (Just x) = bindN stmt i x+	column stmt i = do+		n <- columnIsNull stmt i+		if n then pure Nothing else Just <$> column stmt i+ instance SQLiteDataList a => SQLiteData [a] where 	bindN = bindNList 	column = columnList@@ -224,9 +231,13 @@ foreign import ccall unsafe "sqlite3.h sqlite3_column_type" 	c_sqlite3_column_type :: Ptr Stmt -> CInt -> IO CInt +columnIsNull :: Stmt -> Int -> IO Bool+columnIsNull stmt i = (== Null) <$> columnType stmt i+ columnType :: Stmt -> Int -> IO Type columnType (Stmt ps) i = (<$> c_sqlite3_column_type ps (fromIntegral i)) $ \t ->-	case () of _	| t == sQLITE_INTEGER -> Integer+	case () of _	| t == sQLITE_NULL -> Null+			| t == sQLITE_INTEGER -> Integer 			| t == sQLITE_FLOAT -> Float 			| t == sQLITE_TEXT -> Text 			| t == sQLITE_BLOB -> Blob