packages feed

mysql-json-table 0.1.2.0 → 0.1.3.0

raw patch · 3 files changed

+16/−5 lines, 3 filesdep +http-api-data

Dependencies added: http-api-data

Files

changelog.md view
@@ -1,3 +1,10 @@+## 0.1.3.0+* New instances for `Id`:+  - `FromJSONKey`+  - `ToJSONKey`+  - `FromHttpApiData`+  - `ToHttpApiData`+ ## 0.1.2.0 * Re-export: `ConnectInfo`, `defaultConnectInfo`, `Connection`. * New function: `withSQL`.
mysql-json-table.cabal view
@@ -1,5 +1,5 @@ name: mysql-json-table-version: 0.1.2.0+version: 0.1.3.0 category: Database synopsis: Using MySQL to store id-to-json tables. description: Visit the homepage for more information, or read the readme.@@ -28,6 +28,7 @@     , bytestring     , conduit     , exceptions+    , http-api-data   exposed-modules: Database.MySQL.JSONTable  executable mysql-json-table-test
src/Database/MySQL/JSONTable.hs view
@@ -70,11 +70,12 @@ import Database.MySQL.Simple qualified as SQL import Database.MySQL.Simple.QueryResults qualified as SQL import Database.MySQL.Base qualified as SQLBase-import Data.Aeson (FromJSON, ToJSON)+import Data.Aeson (FromJSON, ToJSON, FromJSONKey, ToJSONKey) import Data.Aeson qualified as JSON import Data.Conduit (ConduitT) import Conduit (ResourceT) import Data.Conduit qualified as Conduit+import Web.HttpApiData (FromHttpApiData, ToHttpApiData)  -- | Open a connection to a MySQL server and apply a function to it. --   The connection is closed both when the function completes or throws an exception.@@ -84,7 +85,9 @@ -- | Row identifier used for table lookups. --   The type parameter indicates the type of data --   stored in the table.-newtype Id a = Id { fromId :: Word64 } deriving (Eq, Ord, Show, ToJSON, FromJSON)+newtype Id a = Id { fromId :: Word64 }+  deriving ( Eq, Ord, Show, ToJSON, FromJSON, FromJSONKey, ToJSONKey+           , FromHttpApiData, ToHttpApiData)  instance SQL.FromField (Id a) where   fromField = ([SQLBase.LongLong], fmap Id . readEither . CByteString.unpack)@@ -132,7 +135,7 @@   , "id BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT"   , ", "   , "data JSON NOT NULL"-  , ")"+  , ") ENGINE=InnoDB"     ]  -- | Create a new JSON table in a MySQL database.@@ -306,7 +309,7 @@   , "`key` " ++ typeToSpec (head $ fst (SQL.fromField @key)) ++ " NOT NULL PRIMARY KEY"   , ", "   , "id BIGINT UNSIGNED NOT NULL"-  , ")"+  , ") ENGINE=InnoDB"     ]  -- | Create a new Id table in a MySQL database.