mysql-simple 0.2.2.2 → 0.2.2.3
raw patch · 8 files changed
+53/−23 lines, 8 files
Files
- Database/MySQL/Simple.hs +27/−5
- Database/MySQL/Simple/Param.hs +1/−1
- Database/MySQL/Simple/QueryParams.hs +1/−1
- Database/MySQL/Simple/QueryResults.hs +11/−3
- Database/MySQL/Simple/Result.hs +2/−2
- Database/MySQL/Simple/Types.hs +1/−1
- README.markdown +4/−4
- mysql-simple.cabal +6/−6
Database/MySQL/Simple.hs view
@@ -4,7 +4,7 @@ -- Module: Database.MySQL.Simple -- Copyright: (c) 2011 MailRank, Inc. -- License: BSD3--- Maintainer: Bryan O'Sullivan <bos@mailrank.com>+-- Maintainer: Bryan O'Sullivan <bos@serpentine.com> -- Stability: experimental -- Portability: portable --@@ -386,9 +386,11 @@ -- > -- > import Database.MySQL.Simple -- >+-- > hello :: IO Int -- > hello = do -- > conn <- connect defaultConnectInfo--- > query conn "select 2 + 2"+-- > [Only i] <- query_ conn "select 2 + 2"+-- > return i -- -- A 'Query' value does not represent the actual query that will be -- executed, but is a template for constructing the final query.@@ -449,11 +451,27 @@ -- The same kind of problem can arise with string literals if you have -- the @OverloadedStrings@ language extension enabled. Again, just -- use an explicit type signature if this happens.+--+-- Finally, remember that the compiler must be able to infer the type+-- of a query's /results/ as well as its parameters. We might like+-- the following example to work:+--+-- > print =<< query_ conn "select 2 + 2"+--+-- Unfortunately, while a quick glance tells us that the result type+-- should be a single row containing a single numeric column, the+-- compiler has no way to infer what the types are. We can easily fix+-- this by providing an explicit type annotation:+--+-- > xs <- query_ conn "select 2 + 2"+-- > print (xs :: [Only Int]) + -- $only_param -- -- Haskell lacks a single-element tuple type, so if you have just one--- value you want substituted into a query, what should you do?+-- value you want substituted into a query or a single-column result,+-- what should you do? -- -- The obvious approach would appear to be something like this: --@@ -461,13 +479,17 @@ -- > ... -- -- Unfortunately, this wreaks havoc with type inference, so we take a--- different tack. To represent a single value @val@ as a parameter, write--- a singleton list @[val]@, use 'Just' @val@, or use 'Only' @val@.+-- different tack. To represent a single value @val@ as a parameter,+-- write a singleton list @[val]@, use 'Just' @val@, or use 'Only'+-- @val@. -- -- Here's an example using a singleton list: -- -- > execute conn "insert into users (first_name) values (?)" -- > ["Nuala"]+--+-- A row of /n/ query results is represented using an /n/-tuple, so+-- you should use 'Only' to represent a single-column result. -- $in --
Database/MySQL/Simple/Param.hs view
@@ -5,7 +5,7 @@ -- Module: Database.MySQL.Simple.Param -- Copyright: (c) 2011 MailRank, Inc. -- License: BSD3--- Maintainer: Bryan O'Sullivan <bos@mailrank.com>+-- Maintainer: Bryan O'Sullivan <bos@serpentine.com> -- Stability: experimental -- Portability: portable --
Database/MySQL/Simple/QueryParams.hs view
@@ -2,7 +2,7 @@ -- Module: Database.MySQL.Simple.QueryParams -- Copyright: (c) 2011 MailRank, Inc. -- License: BSD3--- Maintainer: Bryan O'Sullivan <bos@mailrank.com>+-- Maintainer: Bryan O'Sullivan <bos@serpentine.com> -- Stability: experimental -- Portability: portable --
Database/MySQL/Simple/QueryResults.hs view
@@ -4,7 +4,7 @@ -- Module: Database.MySQL.Simpe.QueryResults -- Copyright: (c) 2011 MailRank, Inc. -- License: BSD3--- Maintainer: Bryan O'Sullivan <bos@mailrank.com>+-- Maintainer: Bryan O'Sullivan <bos@serpentine.com> -- Stability: experimental -- Portability: portable --@@ -41,7 +41,7 @@ -- 'convertResults' [fa,fb] [va,vb] = (a,b) -- where !a = 'convert' fa va -- !b = 'convert' fb vb--- 'convertResults' fs vs = 'convertError' fs vs+-- 'convertResults' fs vs = 'convertError' fs vs 2 -- @ -- -- Notice that this instance evaluates each element to WHNF before@@ -156,7 +156,15 @@ -- | Throw a 'ConversionFailed' exception, indicating a mismatch -- between the number of columns in the 'Field' and row, and the -- number in the collection to be converted to.-convertError :: [Field] -> [Maybe ByteString] -> Int -> a+convertError :: [Field]+ -- ^ Descriptors of fields to be converted.+ -> [Maybe ByteString]+ -- ^ Contents of the row to be converted.+ -> Int+ -- ^ Number of columns expected for conversion. For+ -- instance, if converting to a 3-tuple, the number to+ -- provide here would be 3.+ -> a convertError fs vs n = throw $ ConversionFailed (show (length fs) ++ " values: " ++ show (zip (map fieldType fs) (map (fmap ellipsis) vs)))
Database/MySQL/Simple/Result.hs view
@@ -4,7 +4,7 @@ -- Module: Database.MySQL.Simpe.QueryResults -- Copyright: (c) 2011 MailRank, Inc. -- License: BSD3--- Maintainer: Bryan O'Sullivan <bos@mailrank.com>+-- Maintainer: Bryan O'Sullivan <bos@serpentine.com> -- Stability: experimental -- Portability: portable --@@ -119,7 +119,7 @@ convert = atto ok64 decimal instance Result Float where- convert = atto ok ((fromRational . toRational) <$> double)+ convert = atto ok (realToFrac <$> double) where ok = mkCompats [Float,Double,Decimal,NewDecimal,Tiny,Short,Int24] instance Result Double where
Database/MySQL/Simple/Types.hs view
@@ -4,7 +4,7 @@ -- Module: Database.MySQL.Simple.Types -- Copyright: (c) 2011 MailRank, Inc. -- License: BSD3--- Maintainer: Bryan O'Sullivan <bos@mailrank.com>+-- Maintainer: Bryan O'Sullivan <bos@serpentine.com> -- Stability: experimental -- Portability: portable --
README.markdown view
@@ -24,11 +24,11 @@ and other improvements. Please report bugs via the-[github issue tracker](http://github.com/mailrank/mysql-simple/issues).+[github issue tracker](http://github.com/bos/mysql-simple/issues). -Master [git repository](http://github.com/mailrank/mysql-simple):+Master [git repository](http://github.com/bos/mysql-simple): -* `git clone git://github.com/mailrank/mysql-simple.git`+* `git clone git://github.com/bos/mysql-simple.git` There's also a [Mercurial mirror](http://bitbucket.org/bos/mysql-simple): @@ -39,4 +39,4 @@ # Authors This library is written and maintained by Bryan O'Sullivan,-<bos@mailrank.com>.+<bos@serpentine.com>.
mysql-simple.cabal view
@@ -1,7 +1,7 @@ name: mysql-simple-version: 0.2.2.2-homepage: https://github.com/mailrank/mysql-simple-bug-reports: https://github.com/mailrank/mysql-simple/issues+version: 0.2.2.3+homepage: https://github.com/bos/mysql-simple+bug-reports: https://github.com/bos/mysql-simple/issues synopsis: A mid-level MySQL client library. description: A mid-level client library for the MySQL database, intended to be@@ -16,8 +16,8 @@ subject to the terms of the GPL. license: BSD3 license-file: LICENSE-author: Bryan O'Sullivan <bos@mailrank.com>-maintainer: Bryan O'Sullivan <bos@mailrank.com>+author: Bryan O'Sullivan <bos@serpentine.com>+maintainer: Bryan O'Sullivan <bos@serpentine.com> copyright: 2011 MailRank, Inc. category: Database build-type: Simple@@ -61,7 +61,7 @@ source-repository head type: git- location: http://github.com/mailrank/mysql-simple+ location: http://github.com/bos/mysql-simple source-repository head type: mercurial